I don't understand what am doing wrong here, couldn't find any solutions.
I hope you can help me.
I guess setState in onChange function is not working or maybe another problem here.
I've tried everything to understand the problem but i couldnt'.
I am using ant design pagination to change the pages. thank you.
      componentDidMount() {
        this.setState({
          loading: true,
        });
        const endpoint = `https://api.themoviedb.org/3/movie/popular?api_key=${API_KEY}&language=en-US&page=${this.state.currentPage}`;
        this.getData(endpoint);
      }
    
      getData = (endpoint) => {
        axios.get(endpoint).then((res) => {
          this.setState({
            movies: res.data.results,
            mainImg: res.data.results[0].poster_path,
            loading: false,
            currentPage: res.data.page,
            totalPages: res.data.total_pages,
          });
          console.log(res);
          
        });
      };
    
      onChange = (page) => {
        let endpoint = "";        
        this.setState({ loading: true, currentPage: page });    
        endpoint = `https://api.themoviedb.org/3/movie/popular?api_key=${API_KEY}&language=en-US&page=${this.state.currentPage}`;    
        this.getData(endpoint);
      };
    
      render() {
        const { totalPages, currentPage, movies } = this.state;
        return (
          <div className="main-content">
            <h1>home component</h1>
            <div>
              {movies.map((movie) => {
                return (
                  <ul key={movie.id}>
                    <li>{movie.title}</li>
                  </ul>
                );
              })}
            </div>
            <div>
              <Pagination
                defaultCurrent={1}
                total={totalPages}
                current={currentPage}
                showSizeChanger={false}
                onChange={this.onChange}
              />
            </div>
          </div>
        );
      }
    }
 
     
    