Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update redux state in Accordion renderContent not update the view #437

Open
ciolo opened this issue May 8, 2022 · 4 comments
Open

Update redux state in Accordion renderContent not update the view #437

ciolo opened this issue May 8, 2022 · 4 comments

Comments

@ciolo
Copy link

ciolo commented May 8, 2022

Hi,
I have a rendering problem with <Accordion /> in renderContent prop. I recorded the screen to clarify the problem better.

Screen.Recording.2022-05-08.at.11.33.46.mov

I'll explain the behavior it should have: the button I clicked should decrease the quantity field (above the button) from 2 to 1 but as you can see from the video the component disappears. If I collapse the header up and then collapse it down, the component is displayed again with the right quantity updated. I use redux to manage the status of my application.
Without Accordion it works great, but I would like it to work here too because it's a fanstatic component (congratulations). I have read other issues with similar behavior but have not found any solution

The code:

<Accordion
        activeSections={sections}
        sections={cartItems}
        touchableComponent={TouchableOpacity}
        renderHeader={renderHeader}
        renderContent={renderContent}
        duration={400}
        onChange={updateSections}
        renderAsFlatList={true}
/>

const renderContent = (section: AgencyCartItems, _, isActive: boolean) => {
    return (
      <Animatable.View
        duration={400}
        style={[styles.content, isActive ? styles.active : styles.inactive]}
        transition="backgroundColor">
        {itemsRender(section.data)}
      </Animatable.View>
    );
  };

const itemsRender = (items: CartItem[]) => {
    return (
      <FlatList
        data={items}
        keyExtractor={item => `${item.dish.id}-${item.userID}`}
        renderItem={renderItem}
        showsVerticalScrollIndicator={true}
      />
    );
  };

renderItem is a simple component with nested View, Text and TouchableOpacity.

I hope I was clear.

@wahidshadab
Copy link

I have the same issue

@ciolo
Copy link
Author

ciolo commented Jun 10, 2022

@oblador Any update?

@keremerguner
Copy link

I have the same issue :(

@MichaelAmadheo
Copy link

MichaelAmadheo commented Aug 25, 2022

Try adding flex: 1 on the Animatable.view style

adding flex: 1 to the child of renderContent props fixed that for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants