states not updating inside card
See original GitHub issueHello @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:
- Created 3 years ago
- Reactions:5
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mitjnextt did you ever solve this?
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