Answer the question
In order to leave comments, you need to log in
How to change context in React?
context.js
export ctx = {
changed: false,
}
import ctx
import MyComponent
CTX = createContext(ctx)
<CTX.Provider value={ctx}>
<MyComponent />
</CTX.Provider>
export ctx = {
value: false,
change: function(){
this.value = !this.value
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question