inside the constructor of the provider component in react ?
I want to initialize the context with the state, so I have to define it inside the provider class and not outside.
let context;
class provider extends Component {
constructor() {
//here context= React.createContext({state :this. state} )
}
}
This kinda screams Hacky to me. Is there a reason why you want to initialize the context with that components state? Seems like it's tightly coupling that context
Обсуждают сегодня