fix lifecycle

This commit is contained in:
srgooglo 2022-10-12 14:13:40 +02:00
parent d47df34ed1
commit 26c261f3e7

View File

@ -21,7 +21,7 @@ const NoResultComponent = () => {
} }
// FIXME: Scroll behavior should scroll to next post or the previous one depending on the direction of the scroll // FIXME: Scroll behavior should scroll to next post or the previous one depending on the direction of the scroll
export default class PostsFeed extends React.PureComponent { export default class PostsFeed extends React.Component {
state = { state = {
initialLoading: true, initialLoading: true,
fetchingData: true, fetchingData: true,
@ -80,6 +80,11 @@ export default class PostsFeed extends React.PureComponent {
window.app.shortcuts.remove("postsFeed.scrollDown") window.app.shortcuts.remove("postsFeed.scrollDown")
} }
// avoid to re-render the whole list when props change
shouldComponentUpdate(nextProps, nextState) {
return this.state !== nextState
}
scrollUp = () => { scrollUp = () => {
this.scrollToIndex(this.state.currentIndex - 1) this.scrollToIndex(this.state.currentIndex - 1)
} }