Open runemadsen opened 5 years ago
@runemadsen Could you utilise the shouldComponentUpdate lifecycle method to solve your issue?
Yes, we are currently using shouldComponentUpdate
as a workaround. However:
We have hundreds of connected components that have to do deep equality checks every 100ms
. This is a significant performance hit that could be entirely eliminated with a single if()
statement in react-waterfall
that does not break the current API.
I would argue that the current functionality is undesirable. In a component, I can easily fetch new data and only call setState
if the data is different. This is currently impossible in react-waterfall
, as setState
will be called on every action call, even ones that return nothing. This patterns prevents us from really embracing the store
philosophy because we have no ability to perform heavy data fetching without also introducing heavy component logic. PureComponent
is no help since connect()
creates a new object every time it is called, so the shallow equality check does not work.
I will happily send a PR if it's wanted.
any interest on this? It would solve my problem too :)
@runemadsen A PR will be great and will solve a real issue ;)
@didierfranc @runemadsen @bravomartin ^ here is a PR
Excellent! That's exactly what I need.
Also very clean implementation 👍
@didierfranc please take a look and merge away 💯
First of all, thanks for the great library!
Here's a proposal for a feature: To allow an action creator to return
false
or{}
in order not to re-render the connected components.We're having an issue in our app where we need to have a timeout running every 100ms to fetch updates from a backend. Most of the time, this fetch returns an identical object to that in state and we don't want to re-render all our connected components. So our action creator looks like this (using immutable):
So we return an empty object if the data did not change. However, this still causes
react-waterfall
to re-render every connected component. It seems like it would be easy to implement something where we can returnfalse
or an empty object in order not to makereact-waterfall
re-render.Is this a PR that you would be interested in?