question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

states not updating inside card

See original GitHub issue

Hello @lhandel , I really appreciate your work, but I’m having one issue when I update some states it is NOT being updated inside card.

Can you please guide me here

For example, I have one state loading: true in constructor, In componentDidMount I set to loading: false, But this.state.loading never gets updated value and always returns <Loader> (It is custom component - Which shows loader)

following is my code:

<CardStack
        style={styles.cardstack}
        verticalSwipe={false}
        ref={(swiper) => {
          this.swiper = swiper;
        }}
        renderNoMoreCards={() => (
          <Text style={{fontWeight: '700', fontSize: 18, color: 'gray'}}>
            No more cards :(
          </Text>
        )}
        onSwiped={() => console.log('onSwiped')}
        onSwipedLeft={() => console.log('onSwipedLeft')}>
        <Card style={styles.card}>
        {this.state.loading ? <Loader /> : null}

        </Card>
</CardStack>

Here loader always keep loading even if state changes to false

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

1reaction
ethans333commented, Dec 13, 2020

@mitjnextt did you ever solve this?

1reaction
mitesh-dbcommented, Nov 2, 2020

Also if I set something like this inside <Card>,

<Text style={styles.name_title}>{this.state.f_name}</Text>

f_name never gets updated value

Read more comments on GitHub >

github_iconTop Results From Across the Web

State not updating when using useContext - Stack Overflow
You appear to have duplicated the context state in the Card component. Just swap the Card component's state for what's returned by the...
Read more >
Updating props & state inside renderCard · Issue #189 - GitHub
Hey, When I update the local state or some props. Inside the renderCard function the props/state don't get updated.
Read more >
Why React setState/useState does not update immediately
React setState and useState are asynchronous actions. React setState and useState only create queues for React core to update the state of React...
Read more >
How To Prevent Unnecessary React State Update Re-renders
However, not every state update should result in a re-render. This article covers how to prevent unnecessary state update re-renders by ...
Read more >
React useState Hook - W3Schools
The React useState Hook allows us to track state in a function component. ... To update our state, we use our state updater...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found