In documentation here:
https://reactjs.org/docs/context.html#updating-context-from-a-nested-component
An updater function is placed directly in the state object for the sole purpose of passing it down through context:
this.state = {
theme: themes.light,
toggleTheme: this.toggleTheme,
};
This seems like an odd antipattern. I've never placed a method in state before. Shouldn't state be exclusively for properties that affect rendering and change over time?
In documentation here:
https://reactjs.org/docs/context.html#updating-context-from-a-nested-component
An updater function is placed directly in the state object for the sole purpose of passing it down through context:
This seems like an odd antipattern. I've never placed a method in state before. Shouldn't state be exclusively for properties that affect rendering and change over time?