When placing react native url preview in a flatlist it causes a massive memory leak
lanceylexima opened this issue · 6 comments
When you place a react native url preview within a flatlist, a memory leak occurs that will end up crashing your app.
I'll try to reproduce that problem
When you place a react native url preview within a flatlist, a memory leak occurs that will end up crashing your app.
Hello, can you provide an example of that problem? a repo with that will be helpful 😄
@maherzaidoune Any solution I am also facing this issue
I'm seeing this issue too.
The leak appears to be caused by the logic in componentDidUpdate:
componentDidUpdate(nextProps) {
if (nextProps.text !== null) {
this.getPreview(nextProps.text);
} else {
this.setState({isUri: false});
}
}
Not sure exactly what the issue is but the nextProps.text !== null
comparison seems wrong and that it will call getPreview even if the next has not changed. Going to look into it more later. Will post my findings.
The leak appears to be caused by the logic in componentDidUpdate:
componentDidUpdate(nextProps) { if (nextProps.text !== null) { this.getPreview(nextProps.text); } else { this.setState({isUri: false}); } }
Not sure exactly what the issue is but the
nextProps.text !== null
comparison seems wrong and that it will call getPreview even if the next has not changed. Going to look into it more later. Will post my findings.
yes, that will lead to unnecessary updates, I tried to update that. can you try the newer version