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.

Row changes does not carry the Props and states with it

See original GitHub issue

Hi @naqvitalha, I am making a chat application with realm db, so when ever db is updated with a new message, the list of chats from different users shall be re-ordered according to the messages received time in descending order as WhatsApp does

I am able to update the row positions according to the db update. But there are problem when the position of a row has changed.

Example: Suppose rows are in below order:’

Person A’s Chat row (Containing props and stated of Person A) Person B’s Chat row (Containing props and stated of Person B) Person C’s Chat row (Containing props and stated of Person C)

now if person B sends a message the chat list shall be re rendered and it shall be shown as below, but the props and states are remaining same.

Person B’s Chat row (Containing props and stated of Person A) Person A’s Chat row (Containing props and stated of Person B) Person C’s Chat row (Containing props and stated of Person C)

So next time if any event is send to Person B’s Chat, it is not updating it as we have implemented shouldComponentUpdate checks.

My data Provider is as below: new DataProvider((r1, r2) => { return r1.id !== r2.id }).cloneWithRows(this.state.chats) (ids are unique) So how each row should carry its props? If I have to use rowHasChanged I do not understand how to implement that and the sample examples does not have any example regarding that.

Please help me…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tafelitocommented, Aug 17, 2018

@naqvitalha I’m not sure if the issue I’m having is similar to this one or not. I’m trying to remove items from a list and before an item gets deleted, there is an animation that scales down the row. The problem is that after the animation is run and the data is updated, if I removed row A, then row B will re use row A and because row A was scaled down, now row B is not shown.

here is a quick demo

https://codesandbox.io/s/4j38w51ql7

I tried using optimizeForInsertDeleteAnimations or even disableRecycling and none of that worked.

I had to set the getStableIds to get it to work, but I thought that optimizeForInsertDeleteAnimations was meant for that

0reactions
maxakak1998commented, Nov 14, 2019

Local states will cause issues with recycling because when a component is recycled, it is not unmounted but instead only updated with the new data. The older state will therefore persist in the new item and lead to unpredictable behaviour. You could store such state at a parent level and pass it down as a prop or use the extendedState prop but make a note to not change extendedState too frequently for performance reasons.

I think i have a trouble with this part https://github.com/Flipkart/recyclerlistview/issues/432

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component doesn't Update on Props Change - Stack Overflow
The Form component doesn't "own" row, therefore it's not state and trying to keep these values in sync will only make your head...
Read more >
How to update only specific rows in v7 #2340 - GitHub
I'm using Redux, and for table I'm compute derived data using reselect, after this assign it from props to state. const [data, setData]...
Read more >
Data Grid - State - MUI X
To avoid breaking changes, the grid only saves the column visibility if you are using the new api Make sure to initialize props.initialState.columns....
Read more >
Hooks FAQ - React
Do Hooks replace render props and higher-order components? ... No. There are no plans to remove classes from React — we all need...
Read more >
How To Manage State on React Class Components
This tutorial will first show you how to set state using a static value, which is useful for cases where the next state...
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