-
Notifications
You must be signed in to change notification settings - Fork 424
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
change size of rendered item #56
Comments
onSizeChanged is raised by the scroll container to inform that dimensions of list have been changed. It causes a relayout to fit items accordingly. This only works if you set |
Using react native, I have items in my list and when I click on one I want it to expand in other words I want to change the size of this item in the list and fit the rest of the list below it. my last attempt was as follows:
} this is the method used as the rowRenderer I realize that changing the height property here or at least in the way I did it does not actually change it, this.height has the same value before and after setting it so my question is where can I change the dimensions of the item in the list so the size actually changes and updates list layout |
What you're looking for is non deterministic rendering. Set If your heights are deterministic in nature then you can also just return updated value in layout provider. e.g, (type, dim, index) => {
let dataAtIndex = getData(index)
if(dataAtIndex.isExpanded){
// set heights
}
else {
//set different heights
}
}
If you need further help, try sharing a sample on expo. Will make is much more simple. |
Great that helps thank you. |
Great, closing. |
Good day, I am using extremely big lists and therefore speed is very important. So I went with the second approach. layoutProvider = new LayoutProvider(
); cloneRows(activityModel){
} renderActivity(type, activityModel, index){ render(){
} This works good for expanding and compressing the views however I realized this causes a bug on the list view where if I expand an item, compress it again and scroll down the rest of the list looses its layout and gets part of the previously extended item smashed over it. What could cause the recyclerListView to do this? |
Disabling recycling fixed the problem, but I would still like to know why this is necessary? |
@Fr1kki3 We've had similar layouts here and haven't faced any such issue. Expand collapse never caused this for us. This is definitely unexpected. If you're in a hurry you can go with non deterministic rendering. From looking at your layout it should be pretty fast too. Let's try to find out the issue here, can I take a look at the code if possible? or, can you provide a repro on snack? It would be very helpful to us as well since we have not faced this issue before. The thing is if it's working fine without recycling then that means layout compute is correct. If that's true things should never overlap. One more thing I could not understand the slice logic in the code, can you explain? |
Also |
I've created a small sample. You can try running it on expo using the link: https://expo.io/@naqvitalha/snack-rykYFcoaW If you want to view the code use expo snack link: https://snack.expo.io/rykYFcoaW Color is not changing on snack. There is some issue on re render logic on their end. The latter is the same code built using their sdk. In any case, I'm not seeing the same issue. Check out. |
slice is for paging, if I scroll fast I get white spaces where rows still needs to be rendered, the chance of this increases If there is many icons or images that needs to load(much less than FlatLists though). Paging solved this problem. Thanks for the advice on the dataProvider. I will continue trying to reproduce the problem outside of my production app and let you know ass soon as I am able. At the moment I am also unable to reproduce this problem on snack/expo. |
Okay, great. Regarding the blanks, I have few questions:
From looking at the template it shouldn't go blank. We have lot of complex views here as well and we've been able to prevent blanks in almost all cases. Android fares better on quick scroll compared to iOS though. Also, if you remove paging do you still get the layout issue? |
Only debug mode so far. Both Android and IOS, in my case it was worse on my android tablet.(My device is slower than most by default) The data provider has a valid rowHasChanged, As far as shouldComponentUpdate is conserned I saw it in your snack project yesterday and that is the only place I have seen it till now. Also when I took your snack project scaning the QR code from the first link everything worked good while if I scan it from the second link(code) the size changed but the component it self didn't update on toggle (stayed gray and had the collapsed text) until I commented out the shouldComponentUpdate method then everything went smooth again. I will try to add it and see what happens. Yes on the initial render everything is in collapsed state. Yes removing the paging makes no difference to the layout problem. |
Ok so regarding the layout bug I had a display component inside the row that should enable if the row is expanded. Using a state inside the component to determine if it should be enabled rather than the dataItem sent as prop solved the problem |
@Fr1kki3 Great that you were able to solve it. So, you enabled recycling post that right? But we still don't know the root cause :( Coming back to the blank problem:
Let me know your results! |
Yes recycling is on, regarding the blanks release mode solved it without pager until i opened my extreme case (13000 items) then app runs out of memory the moment I open the view, witch is rather expected to an extend |
It is expected if data is bulky. 13000 items is a lot of data moreover, you'd be getting it over the bridge which means first there'll be a copy of it on native end. Ideally you'll need to do data virtualization in this case. The reason we don't pass data field in layout provider is for the same reason. To do data virtualization you'll need to fetch data inside component and render it yourself. That way once the cell is recycled you'll also let go of the data. Holding 13000 items in memory might be impossible even in cases where individual items are not very large. Paging will help with initial load but what if someone actually pulls in all data by scrolling to the end? |
Since the issue is resolved. Closing this. |
Good day based on the source code I can see that there is an onSizeChange(), but I cannot find anything on how to change the size in such a mater that this event is triggered. Any pointers on what too look for?
The text was updated successfully, but these errors were encountered: