When I rotate the device the cells are upgraded their size only when I scroll, and not on rotation. I've set the canChangeSize={true} props, the _layoutProvider is called once the device is rotated with the right new sizes, but the cell width is expanded or reduced only after some scrolling.
I just looked at the code, looks like it's a regression. Inside VirtualRenderer we now check if renderStackHasChanged or not. In this case it doesn't change so the refresh doesn't occur.
We'll try to fix it in the next release. For now you can manually refresh. Wrap recycler in a view to detect orientation change and when it is detected call _refreshViewability on ref of RecyclerListView. That will do it. Code:
_onLayout = e => {
let orientation = null;
if (e.nativeEvent.layout.width > e.nativeEvent.layout.height) {
orientation = "L";
} else {
orientation = "P";
}
if (this.orientation != orientation) {
this.orientation = orientation;
if (this.recyclerRef) {
//Making sure all compute is done before using setTimeout
setTimeout(() => this.recyclerRef._refreshViewability(), 0);
}
}
};
render() {
return (
<View style={{ flex: 1, alignItems: "stretch" }} onLayout={this._onLayout}>
<RecyclerListView ref={x => this.recyclerRef = x} canChangeSize={true} layoutProvider={this._layoutProvider} dataProvider={this.state.dataProvider} rowRenderer={this._rowRenderer} />
</View>
);
}
Thank you very much with this fix it works! Thank you!
Great! Glad that it worked out. Anyways, the release after the next one will have this fix in core code itself. I'll close this once that is done.
Fixed in v1.2.0
@naqvitalha I am facing the same issue in new version. When the layout orientation is changed the list does not maintain scroll position and also it does not resize.
The issue is marked as fixed. How to use this feature?
Facing the same issue
Most helpful comment
@naqvitalha I am facing the same issue in new version. When the layout orientation is changed the list does not maintain scroll position and also it does not resize.
The issue is marked as fixed. How to use this feature?