Higher-Order Component for adding "shouldComponentUpdate" to components. It supports easy to set shortcuts.
npm install react-should-component-updateHigher-Order Component for adding shouldComponentUpdate to components. It supports easy to set shortcuts.
``sh`
npm install --save react-should-component-update
`ts
import shouldComponentUpdate from 'react-should-component-update';
import MyComponent from './my_component';
// Path shortcut
// shouldComponentUpdate ( path )( Component )path
// Updates the component if the prop at changed
shouldComponentUpdate ( 'myprop.foo' )( MyComponent );
// Path toggle shortcut
// shouldComponentUpdate ( [path, valuePath] )( Component )path
// Updates the component if the prop at becomes equal-to/different-from the prop at valuePath
// This is useful when your component should be re-rendered only when it gets selected/unselected
shouldComponentUpdate ( ['myprop.foo', 'foo'] )( MyComponent );
// Plain function
// shouldComponentUpdate ( myFn )( Component )myFn
// Updates the component if returns true
function myFn ( props, nextProps ) {
// Update logic here
}
shouldComponentUpdate ( myFn )( MyComponent );
// Boolean shortcut
// shouldComponentUpdate ( bool )( Component )
shouldComponentUpdate ( false )( MyComponent );
// Multiple rules
// Updates the component if at least one updating rule passes
shouldComponentUpdate ( 'myprop.bar', ['myprop.foo', 'foo'], myFn )( MyComponent );
``
- react-log-updates: Log the number of updates occurring, broken down by components.
- react-selectr: Simple selector for React components.
MIT © Fabio Spampinato