rs
redux-spy
npm i redux-spy
rs

redux-spy

A higher order component decorator to read from a Redux store without subscribing to all its changes

by Erik Rasmussen

1.0.1 (see all)License:MITTypeScript:Not Found
npm i redux-spy
Readme

Redux Spy

NPM Version NPM Downloads Build Status codecov.io

redux-spy works like react-redux's connect() decorator, except that, rather than subscribe to changes in the Redux store, which causes a rerender, it gives its wrapped component a function with which to query specific slices of the Redux store.

It works by using a non-rendering child component that is subscribed to the Redux store.

Screencast

This is a screencast of the example app running.

screencast

Why???

This will not be a hugely popular library because it is only useful in rare edge cases.

I am currently working on a redesign of redux-form, which contains a large outer component, that is very expensive to rerender, but that occasionally (e.g. form submit) needs access to state in Redux that changes on every single keystroke. Rather than rerender the whole form every time, redux-spy will allow my large component to spy on the Redux state only when it needs to.

API

reduxSpy(mapStateToKeys)

mapStateToKeys is very similar to mapStateToProps that you would give to connect(), except it doesn't accept an ownProps second parameter.

Props provided to your decorated component

spy(key:String) : Function

A function to call to get the corresponding value from the Redux state. The key parameter much match on the keys in the map returned from mapStateToKeys.

Downloads/wk

1

GitHub Stars

29

LAST COMMIT

7yrs ago

MAINTAINERS

1

CONTRIBUTORS

0

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
1.0.1
latest
7yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate