React JS Error: Invalid attempt to destructure non-iterable instance

I caused this error a few times because whenever I write a useState hook, which I would do often, I’m used to using an array to destructure like so:

const [ state, setState ] = useState();

But my custom hooks usually return an object with properties:

const { data, isLoading } = useMyCustomFetchApiHook();

Sometime I accidentally write [ data, isLoading ] instead of { data, isLoading }, which tiggers this message because you’re asking to destructure properties from an array [], when the object you’re destructuring from is an object {}.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)