AdeleD / react-paginate

A ReactJS component that creates a pagination
MIT License
2.76k stars 628 forks source link

Fix forcePage to control page properly #496

Open tlatmdxo123 opened 1 year ago

tlatmdxo123 commented 1 year ago

For forcePage to function correctly as a controlled component, it is more appropriate to directly assign the forcePage prop instead of using state for managing it. Instead of setting forcePage in the initial state and then matching it in componentDidMount, utilizing the forcePage prop directly is recommended. If forcePage and the internal selected state are in sync, there should be no issues. However, if different values are assigned, the page will be activated using the selected state and then revert back to forcePage.