Declarative shouldComponentUpdate wrapper
npm install should-not-updateSimple component utilizing the shouldComponentUpdate lifecycle hook. Wrap it around child components that you don't want to rerender on property changes.
``javascript
import ShouldNotUpdate from 'should-not-update'
const MyComponent = ({ someProp }) => (
This is not updating on property change
)
`ShouldNotUpdate$3
By default, will render as a div element, but that can be changed by setting the component prop, which accepts either a tag name string (such as 'div' or 'span')`javascript``
or a React component type (a class or a function), which should render their children to be useful.javascript
const MyComponent = ({ children }) => (
{children}
)
`exceptWhen$3
Sometimes you want child components to re-render under certain conditions. You can add these conditions by setting the prop.`javascript`
const MyComponent = ({ someProp }) => (
This only updates on property change when someProp is 42
)
, component and exceptWhen are directly passed to the rendered component.
`javascript
const MyComponent = ({ someProp }) => (
This is not updating on property change
)
`
$3
Amongst others, one possible use case is not re-rendering static children of a react-motion spring animation on every animation frame.
`javascript
import { Link } from 'react-router'
import { Motion, spring } from 'react-motion'const OffCanvas = ({ isVisible }) => (
{style => }
);
``