mohmdalfaha
mohmdalfaha

Reputation: 3

I am getting context value undefined in the child component using contextType in an expo app

I am trying to use context api in my app, the way i am trying to use is https://reactjs.org/docs/context.html#classcontexttype

here's a snack that I need to fix https://snack.expo.io/@mohmdalfaha/contexttype-example the context value is always undefined??

Upvotes: 0

Views: 259

Answers (1)

Jitesh Manglani
Jitesh Manglani

Reputation: 485

There is error in your import in child component. As you are exporting AppContext as default you can't import in {}. You can import constant in {}. Here's a snack for that https://snack.expo.io/ByQkOVgXS

Upvotes: 1

Related Questions