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 {}.