npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

redux-refetch

v1.0.1

Published

An automated refetcher for react-redux

Readme

Redux Refetch

A simple automated data refetcher for using react-redux. The basic use case is when you have some data that needs to be refetched anytime there is a change in some of the underlying properties. However, often times there is no point in refetching the data as the component which renders it may not be mounted, so you end up repeating the same pattern of

class ExpensiveComponent extends Component {
  componentWillUpdate(newProps, newState){
    if(this.shouldRefetch(this.props, newProps)){
      this.refetchingFunction()
    }
  }

  shouldRefetch(oldProps, newProps){
    return oldProps.prop1 !== newProps.prop1
        || oldProps.prop2 !== newProps.prop2
        ...
  }
}

within every component that renders some server side data.

Installation

To install via npm, run

npm install --save redux-refetch

Usage

import connect from 'redux-refetch'

class ExpensiveComponent extends Component {
  render(){
    ...
  }
}

mapStateToDependencies(state, ownProps) {
  return {
    dependency1: dependency1Selector(state),
    ...
  }
}

mapDispatchToRefetch(state, ownProps) {
  return {
    refetchFunction,
    refetchFunction2,
    ...
  }
}

export default connect(
  mapStateToProps,
  mapStateToDependencies,
  mapDispatchToProps,
  mapDispatchToRefetch
)(ExpensiveComponent)

mapStateToProps and mapDispatchToProps are the same as they are within react-redux.

Note: You cannot use the keys __dependencies or __refetch for any props, both manually supplied props i.e. <Component prop={'prop'}/> and when creating the mapStateToProps or mapDispatchToProps function. These are interally used keys when building the container.

API

connect(?mapStateToProps, ?mapStateToDependencies, ?mapDispatchToProps, ?mapDispatchToRefetch, ?options)

The only part of this package. It is an enhanced version of react-redux connect. It not only allows you to add redux action creators and properties from state as props within a react component, but it also allows you to ensure that, when one of the dependencies given in mapStateToDependencies, all of the refetching functions are called too.

Arguments
  • [mapStateToProps(state, [ownProps])] (Function): This is the same as in react-redux. Documentation for that can be found here

  • [mapStateToDependencies(state, [ownProps])] (Function): This function returns an object of all dependencies for the refetcher. It takes the redux state and the props supplied to the component as arguments and you should return an object containing all of the dependencies. When any of the dependencies supplied changes then all of the functions defined in mapDispatchToRefetch will be called.

  • [mapDispatchToProps(state, [ownProps])] (Function): This is the same as in react-redux. Documentation for that can be found here

  • [mapDispatchToRefetch(state, [ownProps])] (Function): A function which takes both the redux state and the props supplied when rendering the component. It should return an object with each of a functions to call when the any of the dependencies defined in mapStateToDependencies change.

  • [options] (Object): If specified customizes the connector for both redux-refetch and react-redux. Possible options are as shown below.

    • [equalityCheck] (Function): If supplied will test whether the dependencies have changed. If this argument is not supplied then it will default to ===.
    • [mergeProps] (Function): If specified, it is called with the results of mapStateToProps, mapDispatchToProps and props and expects the final props object as a return. More documentation on this can be found here.
    • [connectOptions] (Object): These are the options that get passed into connect from react-redux. Again more complete and well rounded documentation can be found here

Contributing

Feel free to open a PR or submit an issue if you want to suggest or improve something