focal
focal copied to clipboard
Fix double re-render in LiftWrapper and migrate it to PureComponent
what was done:
- migrate
LiftWrapper
to PureComponent - move
LiftWrapper
logic to namespace - slight refactor Render{One,Many}
- eliminate double re-render (because of setState)
- bonus: added focal bench to https://github.com/krausest/js-framework-benchmark/pull/889
Context
In the previous LiftWrapper, we used setState method to re-render our component when we subscribe to new props AND initially render our component. As an example: during the very first render, we start rendering our renderCache as null and then synchronously re-render it via setState . Since by design Focal does need sync observable emit, I optimized first render to render initial observable value without invoking setState reconciliation (via refs).
todo before merge:
- [x] add MR description about the issue and the fix (and change title)
- [x] [not that easy :(]add unit tests for re-renders (currently only
renderToStaticMarkup
is in unit-tests) - [x] [no results] investigate, how to test "waste render" in react via unit-tests (see screenshots)
- [x] perform benchmarks
- [x] [it works, but hard to compare values between runs, since they are too small and there is a lot of deviatiosn] investigate elm benchmark
Double re-render fix demo:
https://user-images.githubusercontent.com/13982649/126957306-fbc62a3b-435e-4adf-8301-2ab9b36c6180.mov
@KatSick benchmark results look awesome! thanks!
@blacktaxi what do you think about those changes? Are we safe to merge it now, or you have any other objections?