DEV Community

Discussion on: variable passed through context does not change in the child when changing in the parent and vice versa

Collapse
 
dance2die profile image
Sung M. Kim

Are you getting any errors?

getAccountData needs to bind this in constructor or should be declared with an arrow syntax.

Collapse
 
dieldore profile image
Dieldore • Edited

No mistakes
If i write

this.state = {
      id: '123',
};

then it will work.
this attaches correctly. But setState or timers do not change the object that is inside UserContext.Consumer