windmill-react-ui icon indicating copy to clipboard operation
windmill-react-ui copied to clipboard

onChange function on pagination component shouldn't be ejecuted on the firtst render.

Open davs20 opened this issue 4 years ago • 0 comments

hello @estevanmaito , im using the pagination component and I discover that onChange funtion is ejecuted on the first render, that's wrong because, onChange function only should be ejecuted when the page is changed, so, I was thinking and I found a problem in the useEffect that handle this function, the problem is that useEffect always will be ejecuted on first render , even if you don't change the state, so my proposal is create a reference using useRef , with that , useEffect will know when the component is rendered for first time.

https://github.com/estevanmaito/windmill-react-ui/blob/fba3fb0cfae5fac52f195b03d3fc010084908256/src/Pagination.tsx#L158

davs20 avatar Jan 04 '22 17:01 davs20