React-native-collapsible: Nested Collapsible error

Created on 15 Sep 2019  路  2Comments  路  Source: oblador/react-native-collapsible

I am using nested Collapsibles in a structure like this:

FlatList ---> Collapsible in each item ---> FlatList in each Collapsible ---> Collapsible in each item.

On IOS this is working fine, however on Android I get the following error when trying to expand the inner Collapsible:

Screenshot_1568553747

It appears that for some reason, one of the Collapsibles (the outer one would be my guess) is getting "NaN" for height property which leads to a crash.

I managed to fix this by adding the following check to Collapsible.js (line 150):

    this._animation = Animated.timing(this.state.height, {
      toValue: height ? height : 0,          // <------ Here
      duration,
      easing,
    }).start(() => {
      if (this.unmounted) {
        return;
      }
      this.setState({ animating: false }, () => {
        if (this.unmounted) {
          return;
        }
        this.props.onAnimationEnd();
      });
    });

It seems like a bug to me, you might be able to reproduce this.

react: 16.8.3
react-native: 0.59.10
react-native-collapsible: 1.5.0

Most helpful comment

created a PR for this, hope it get merged

All 2 comments

created a PR for this, hope it get merged

I hope this gets merge soon too, in the meantime I just forked your fork :)

Was this page helpful?
0 / 5 - 0 ratings