yasinsolak / react-native-accordion-view

react-native-accordion-view
4 stars 0 forks source link

EXPO SDK 40 #2

Open crismarucci opened 3 years ago

crismarucci commented 3 years ago

Hi! I was using this great component without any problem, but I updated to SDK 40 in Expo and now is not working. It doesn't give me an specific error, but when I try to open the accordion nothing happens (well, not NOTHING... the arrow changes but the content doesnt' appear). My expo version is 4.1.6. I would be grateful if you could help me.

crismarucci commented 3 years ago

I found the problem (I think), but I can't understand why it's happening. On method "handlyOnLayout" I got zero (0) in property e.nativeEvent.layout.height, but it's random. In some cases, I get the correct value. If I put some hard code value (like 300) it works all the time. Any ideas? Tks.

  const handleOnLayout = (e: LayoutChangeEvent) => {
    if (!containerHeight) {
      setContainerHeight(e.nativeEvent.layout.height)
      console.log(e.nativeEvent.layout)
      //setContainerHeight(300)
    }
  }
yasinsolak commented 3 years ago

Hello, yesterday I found that the error is caused by there. But I could not find what exactly SDK 40 is breaking. I'll investigate a little more for you now.

crismarucci commented 3 years ago

Hello @yasinsolak ! Any update on this issue? I tried to understand it by my own means but couldn't find a workaround yet. Thanks for your help.

crismarucci commented 3 years ago

@yasinsolak I found a workaround:


      <Animated.View        
        style={[styles.items, { height }]}>
        <View
          **onLayout={(ev)=>{setContainerHeight(ev.nativeEvent.layout.height + 10)}}**
          style={[
            styles.item,
            subContainerStyle,
            {
              borderBottomLeftRadius: containerRadius,
              borderBottomRightRadius: containerRadius
            }
          ]}>
          {children}
        </View>
      </Animated.View>