1.0.3 • Published 5 years ago

react-selectr v1.0.3

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

React Selectr

Simple selector for React components.

Useful when using state managers such as unstated.

Using this library you can pass your components only the props they need to render, instead of the whole state. This will avoid unnecessary re-renders and therefore improve performance.

Install

npm install --save react-selectr

Usage

import selectr from 'react-selectr';
import MyComponent from './my_component';

function propsSelector ( props ) {
  return {
    foo: props.foo,
    bar: props.getBar ()
  };
}

// Pure components
// MyComponent will only receive the selected props, and if they don't change it won't be re-rendered

selectr ( propsSelector )( MyComponent );

// Unpure components
// MyComponent will only receive the selected props, but even if they don't change it will always re-render

selectr ( propsSelector, { pure: false } )( MyComponent );

Related

License

MIT © Fabio Spampinato

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago