I have an UI built in Flux/React that mimics an OS windows system. User can move, minimize, and resize windows but also drag'n'drop icons between windows. I have main Desktop component which polls LayoutStore and builds children based on layout data.
It turns out however that rerendering the virtual DOM tree with more elements takes long enough to impair app responsiveness sometimes which is bad for transition animations. I already gave up on updating state at 60fps - I just update layout store after user drops an element. I was thinking about ways to limit render
calls since I know that most changes to the layout affect child components very selectively - there is low chance that a given layout state change affects more than one particular component.
What I came up with is keeping a dirty
or stateVersion
variable in LayoutStore for each larger component (i.e. a window) and passing it in props so that each component could check if it was affected very fast without worrying about complexity of state representation (no deep comparisons, immutable copies, etc.) Also I prefer the second way cause I can just bump component's stateVersion
each time I mess with its properties and don't need to unset dirty
back in the store after emitting change
.
Since I'm very new to React - is it a sane approach given my constraints or is there a better standard solution?