react-controlled-reflow
Reflow is a wrapper for react components that gives you control over render updates. You are smarter than react. Only you know what really needs to update the UI.
Simple as that. Nothing more.
But why?!
1. There are many libraries out there that have a terrible rerender behaviour.
Fact.
2. Arrow function updates render
> this !== this> true
3. Event handler creator updates render
> const createHandlerFor = this>> !== > true
4. Arrays
> "foo" "bar" !== "foo" "bar"> true
5. Config Objects
> borderColor: "red" !== borderColor: "red" > true
This issues in a massive overhead. A form usually doesn't have to rerender totally when the state changes.
Just wrap the component with Reflow
and stop unnecessary render cycles.
Props
Prop | Type | Description |
---|---|---|
trigger | any | undefined |
The value that triggers the rerender |
oneOf | any[] | undefined |
An array that triggers the rerender if an item changes |
Examples
trigger
Bad update behaviour
Before: TextField rerenders even nothing changes.
After : TextField only rerenders when userName changes
Event handler creator
Before: TextField rerenders even nothing changes.
After : TextField only rerenders when userName changes
Arrow functions
Before: TextField rerenders even nothing changes.
After : TextField only rerenders when userName changes
oneOf
Arrays
Before: Items is an array. So rerenders on every render
After: List only rerenders if an array items changed
Complex Arrays
Before: Items is an object array. So rerenders on every render
After: List only rerenders if an array items changed