Skip to content

Move space state to global state #69

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
aeagle opened this issue Apr 19, 2020 · 3 comments
Closed

Move space state to global state #69

aeagle opened this issue Apr 19, 2020 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@aeagle
Copy link
Owner

aeagle commented Apr 19, 2020

Currently state for spaces contained in a parent space is kept at the parent space however keeping this in sync with standard React state methods is proving to be difficult. Addition and removal of spaces as well as changing their properties has to propagate a state change to Fill spaces in the same parent/layer.

The current implementation relies on a side effect in the render method of a space to fulfill the implementation for the <Fill /> space and stacked spaces. This has manifested itself as a React warning "Cannot update a component from inside the function body of a different component" in the latest versions of React.

As use of space components technically drive the state, moving the state to a global state container will potentially alleviate these issues by retaining complete control over the re-rendering of space components that have changed.

A existing global state container (i.e. MOBX, Redux) is potentially overkill and will add unnecessary overhead so and a very specific custom global state container is preferable. Potentially this global state container may be able to be used as a backend for different frameworks.

Initial basic implementation on global-state branch in Experimental.tsx fixes #64.

@aeagle aeagle added enhancement New feature or request in progress labels Apr 19, 2020
@Kyliathy
Copy link

+1 for this one :). Just ran into it and spent about 30 minutes trying to fix my code :D, especially as I couldn't see the warning on your example website. But after a simple code from your website also failed I finally checked "Issues" :D.

I also agree Redux would be overkill. Not an expert in React, but maybe this is a situation when React's context is good enough? Or if not, Flux?

@aeagle aeagle added this to the 0.2.0 milestone Apr 27, 2020
@aeagle
Copy link
Owner Author

aeagle commented Dec 10, 2020

Added and ready for 0.2.0 release. Latest prerelease Implementation in v0.2.0-beta.10

@aeagle aeagle closed this as completed Dec 10, 2020
@aeagle
Copy link
Owner Author

aeagle commented Dec 14, 2020

Version v0.2.0 released now

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants