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

limit is NaN with prefetch:false #60

Open
legendar opened this issue Oct 9, 2020 · 1 comment
Open

limit is NaN with prefetch:false #60

legendar opened this issue Oct 9, 2020 · 1 comment

Comments

@legendar
Copy link
Collaborator

legendar commented Oct 9, 2020

No description provided.

@chernichenko
Copy link

withPosts.js

import { withInfinityList } from '@ds-frontend/resource'

export default withInfinityList(
  {
    namespace: 'feed',
    endpoint: 'content/posts/search',
    queries: ['search', 'offset', 'limit']
  },
  {
    defaultParams: {
      offset: 0,
      limit: 10
    },
    prefetch: false,
    Loader: ({ children }) => children
  }
)

PostsContainer.js

export default function PostsContainer(props) {
  const { feed, search } = props

  useEffect(() => {
    search.length > 2 && feed.fetch({ offset: 0, limit: 10, ...feed.filters, search })
  }, [search])

  return <PostsView {...props} />
}

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

No branches or pull requests

2 participants