react-hooksreact-contextcreatecontext

useContext give error while accessing the values


How can i fix it "useTheme is not a function or its return value is not iterable" while using create context and also i can't access values of createContext it gives error: "not define" while using those.

my context provider;

'app.js' cant access to the provider values.

enter image description here

error: "useTheme is not a function or its return values is not iterable" while using UseTheme method


Solution

  • the problem is that the context is an object and you destructure it using the { } while in your code you used [ ] code