Need to delay the api update. Beacause when results of the api renders, some of the components delays a little bit and sometimes doesnt print it.
Tried the input user delay, but it was only for typing, so try differents ways to delay the api, but no luck
componentDidUpdate(prevProps, prevState) {
if (prevState.userInput !== this.state.userInput ||
prevState.page !== this.state.page) {
if (prevState.userInput !== this.state.userInput)
this.setState({page: 1});
if (this.state.userInput === '' &&
(prevState.userInput !== this.state.userInput)) {
fetch(API_POPULAR)
.then(response => response.json())
.then(json => {
this.setState({
selection: 'popular?',
items: json.results,
isLoading: false,
page: 1,
max_pages: json.total_pages
});
});
}