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 🙏

© 2024 – Pkg Stats / Ryan Hefner

resurrection

v1.2.18

Published

State management library that follows Flux / Redux / Thunk architecture but uses React's latest useContext and useReducer hooks.

Downloads

129

Readme

ContextStore

State management library that follows Flux / Redux / Thunk architecture but uses React's latest useContext and useReducer hooks.

Props

ContextProvider props you may want to specify include:

  • name: String
  • context: Object
  • reducers: Function | Object
  • initialState: Object
  • props: Object
  • initializer: Function
  • children: Node
/**
 * @typedef {Object} ContexStoreProps
 * @property {String|Number=} name - the name of the ContextStore
 * @property {Object} context - allows you to supply a custom context instance to be used by resurrection.
 * You need to pass the instance of your context to both <ContextProvider /> and your connected component.
 * You may pass the context to your connected component either by passing it here as a field of option, or as a prop to your connected component
 * in rendering.
 * @property {Function|Object.<String, Function>=} reducers - first object to compare
 * @property {Object.<String, *>=} initialState - the initial state of the reducer
 * @property {Object.<String, *>=} props - passed from an HOC that controls the state of the store use this if you want prop changes to
 * overwrite the state
 * @property {Function=} initializer - sets the initial state of the reducer
 * @property {ReactNode} children - the child components that will consume the store
 */

connect arguments you may want to specify include:

  • context: object
  • pure: boolean
  • areStatesEqual: function
  • areOwnPropsEqual: function
  • areStatePropsEqual: function
  • areMergedPropsEqual: function
  • forwardRef: function
/**
 * Connects a Component to the ContextStore
 * @typedef {Object} ConnectOptions
 * @property {Object} context - a context consumer.
 * You need to pass the instance of your context to both
 * <ContextProvider /> and your connected component.
 * You may pass the context to your connected component either
 * by passing it here as a field of option,
 * or as a prop to your connected component in rendering.
 * @property {Boolean} pure - when options.pure is true,
 * connect performs several equality checks that are used to avoid unnecessary calls to
 * mapStateToProps,
 * mapDispatchToProps,
 * mergeProps,
 * and ultimately to render.
 * These include areStatesEqual,
 * areOwnPropsEqual,
 * areStatePropsEqual,
 * and areMergedPropsEqual.
 * While the defaults are probably appropriate 99% of the time,
 * you may wish to override them with custom implementations for performance or other reasons.
 * @property {Function=} areStatesEqual - when pure, compares incoming store state
 * to its previous value.
 * areStatesEqual: (next: Object, prev: Object) => boolean
 * @property {Function=} areOwnPropsEqual - when pure, compares the result of ownProps
 * to its previous value.
 * areOwnPropsEqual: (next: Object, prev: Object) => boolean
 * @property {Function=} areStatePropsEqual - when pure, compares the result of mapStateToProps
 * to its previous value.
 * areStatePropsEqual: (next: Object, prev: Object) => boolean
 * @property {Function=} areMergedPropsEqual - when pure, compares the result of mergeProps
 * to its previous value.
 * areMergedPropsEqual: (next: Object, prev: Object) => boolean
 * @property {Function=} forwardRef - If {forwardRef : true} has been passed to connect,
 * adding a ref to the connected wrapper component will actually
 * return the instance of the wrapped component.
 */

/**
 * This function simulates Redux's connect API
 * @param {MapStateToProps=} mapStateToProps - reducer dispatch API
 * @param {MapDispatchToProps=} mapDispatchToProps - reducer state
 * @param {Function=} mergeProps - function to merge props
 * @param {ConnectOptions=} options - options
 * @returns {React.memo|React.FunctionComponent} - a connected component
 **/

export default (mapStateToProps, mapDispatchToProps, mergeProps, options)(SomeChildComponent);

See also react-redux's connect

Hooks useDispatch useSelector

License

MIT © nathanhfoster