Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async items #1

Open
michalpokojski opened this issue Mar 15, 2019 · 3 comments
Open

Async items #1

michalpokojski opened this issue Mar 15, 2019 · 3 comments

Comments

@michalpokojski
Copy link

michalpokojski commented Mar 15, 2019

Super useful component :) Great work!

I've found one bug. It doesn't work with async items.

simple fix:

useEffect(() => {
  dispatch({ type: 'reset', initialState: props })
}, [props.items])

and everything works fine :)

I also tried on my side to trigger almost the same thing by using pagination.onResetPage() but useCallback from react memoize initial props so useEffect has come in handy 👍

@dylangarcia
Copy link
Owner

@michalpokojski so sorry I didn't see this! Glad you like it.

Can you provide a minimal repro for your issue? I think if I just add props to the dependency array of useCallback it should fix it!

@michalpokojski
Copy link
Author

michalpokojski commented Apr 3, 2019

Actually, it's already there:

const onResetPage = useCallback(
    () => dispatch({ type: 'reset', initialState: props }),
    [props.items.length]
  )

but somehow it doesn't work, will try to reproduce it somewhere

@edit Something like this: https://codesandbox.io/s/vv5q4jx180

@drixie
Copy link

drixie commented Nov 3, 2020

@dylangarcia This issue still exists.

Thanks for a very simple solution!

Also, is it possible to have a method that lists out page numbers in a specified format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants