I am using react-infinite-scroll to render a feed of data. Whenever the user changes their settings, I want to refresh the feed of data.
To do this, I have a key prop for the InfiniteScroll component. The idea being whenever the user changes their settings
this.state.renderCountis incremented by 1 insetStateReact notices that the key prop of
InfiniteScrollis different, and re-renders the component from scratch.<Content style={{ padding: "0px 20px" }}> <InfiniteScroll key={this.state.renderCount} style={{ width: "100%", height: "100%" }} pageStart={0} loadMore={this.loadPosts.bind(this)} hasMore={true} loader={<div>Loading....</div>} useWindow={false} > {listItems} </InfiniteScroll> </Content>
The refresh code is in componentDidUpdate and is called if I determine that a refresh is needed:
this.setState({ renderCount: this.state.renderCount + 1 })
However, the component is not reset. Why is this?