I'm writing a small React Native app and I'm trying to use Flow, but I can't really get a proper tutorial about it anywhere.
I keep getting the error: destructuring (Missing annotation)
about the ({ station })
in the 1st line of this code:
const StationDetail = ({ station }) => {
const {
code,
label,
} = station;
station
is a json response and code
and label
are strings
inside that json.
How do I fix the error/warning?
I would write this as
type StationType = {
code: String,
label: String,
}
function StationDetail({ station } : {station : StationType}) => {
const {
code,
label,
} = station;
It's necessary to declare the type of the object parameter that the function accepts.