I need to do this to avoid this behavior:
import _ from 'lodash';
import RCCollapse from 'rc-collapse';
import { shouldUpdate, shallowEqual } from 'recompose';
const Collapse = shouldUpdate(
( props, nextProps ) => (
!shallowEqual( _.omit( props, 'children' ), _.omit( nextProps, 'children' ) )
|| !_.isEqual( props.children.map( v => v.key ), nextProps.children.map( v => v.key ) )
)
)( RCCollapse );
const Panel = shouldUpdate(
( props, nextProps ) => !shallowEqual(
_.omit( props, 'onItemClick' ),
_.omit( nextProps, 'onItemClick' )
)
)( RCCollapse.Panel );
Whether the onItemClick function changes or not does not affect the rendering, so you do not need to rerender when this prop changes.