K
K
Kirill Ivanov2020-02-11 23:57:35
React
Kirill Ivanov, 2020-02-11 23:57:35

Why is the application not redrawing after state update?

Hello! There is a small table with data in React, and pagination is attached to it. According to it, the output of 5 objects is configured. I want to add the ability to select the number of displayed objects so that you can display 3, 5, 10, etc. at the request of the user.

To do this, I created buttons under the table, and hung a handler on each (with different numbers, respectively)

onClick={()=>this.setState({pageRangeDisplayed: 3})}
, which changes the corresponding field in the state to the desired number (3.5, etc.). Well, further from the state, this number comes to the props of the component, which draws the table.

But I ran into a problem: after onClick, the state seems to change (checked through console.log), but visually nothing happens and the component is not redrawn. Apparently I'm missing some banal thing, but I can't figure out which one, I'll be grateful for any ideas.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Ivanov, 2020-02-13
@pashkevich-d

False alarm, used react-paginate to display pagination and inattentively looked at how it works, problem solved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question