Skip to content

All Panels make a new render when opening/closing a Panel. #94

@bertho-zero

Description

@bertho-zero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions