Skip to content

Conversation

@smeijer
Copy link
Member

@smeijer smeijer commented May 31, 2020

Building further upon #58, and #68, I've moved all shared state management to the context. I believe this greatly simplifies state management.

The context provider is placed now a level deeper, directly in Playground, instead of wrapping the router as well. This enables us to provide the initialValues directly to the context.

To implement state management in the context, I've implemented a state reducer. All components that use the state, now import a state object and a dispatch function, and that's it.

No more editor refs or directly setting editor values from within other components. And the parser is now called directly upon state mutation, instead of later via useEffect.

In the scope of the "where to save state" discussion that was being held in #58, I've added an onChange handler to the context. This onChange handler can be used to sync state to storage locations. As can be seen in Playground and Embedded.

@smeijer smeijer self-assigned this May 31, 2020
@smeijer smeijer added the chore label May 31, 2020
@smeijer smeijer merged commit d359e82 into develop Jun 1, 2020
@smeijer smeijer deleted the feature/state-management branch June 1, 2020 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants