Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

contextAPI return state with undefined

$
0
0

I'm using contextAPI with useState, and the initial value is an Object with Themes.

but when i give console.log this return undefinedenter image description here

and i created a custom hook for this

enter image description here

I used provider in App.

when i do this

const { themeMode } = useToggleTheme()console.log(themeMode) //Undefined

I tried using InitialValues in createContext, but when i use the setThemeMode, that doesnt work. I have other context just using boolean, that returns undefined too. but when i use setXXX that update the state


Viewing all articles
Browse latest Browse all 6290

Trending Articles