Skip to content

Only re-render if action creator returns an object #99

@runemadsen

Description

@runemadsen

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):

{
  actionsCreators: {
    syncData: async ({ data }) => {
      const newData = await api.get('/data');
      return data.equals(newData) ? {} : { data: newData };
    }
  }
}

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 return false or an empty object in order not to make react-waterfall re-render.

Is this a PR that you would be interested in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions