Description
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.
- Potential to fix Possible side effect in other components (warning with React 16.13.0) #64
- Potential to fix Create Positioned space #60
- Potential to fix Switching elements does not update positions correctly #52
Initial basic implementation on global-state branch in Experimental.tsx fixes #64.