oblador / react-native-collapsible

Animated collapsible component for React Native, good for accordions, toggles etc
MIT License
2.44k stars 451 forks source link

Collapsible doesn’t render children when initially it is not collapsed (renderChildrenCollapsed) #402

Open adrianklimek opened 3 years ago

adrianklimek commented 3 years ago

When collapsed and renderChildrenCollapsed are both set to false, children component is not rendered. I was able to fix it locally by modifying shouldRenderChildren condition, but I am not sure about the rest of the condition, maybe it could be simplified somehow or other changes are necessary.

Before:

const shouldRenderChildren = renderChildrenCollapsed ||
  ((!collapsed || (collapsed && animating)) &&
    (animating || measuring || measured));

After:

const shouldRenderChildren =
  (renderChildrenCollapsed || !collapsed) ||
  ((!collapsed || (collapsed && animating)) &&
    (animating || measuring || measured));