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

[BUG] useSelect Ignores fetchSize #2692

Closed
vinclou opened this issue Oct 10, 2022 Discussed in #2691 · 3 comments · Fixed by #2704
Closed

[BUG] useSelect Ignores fetchSize #2692

vinclou opened this issue Oct 10, 2022 Discussed in #2691 · 3 comments · Fixed by #2704
Labels
bug Something isn't working

Comments

@vinclou
Copy link

vinclou commented Oct 10, 2022

Discussed in #2691

Originally posted by vinclou October 10, 2022

Deps:

`"@pankod/refine-antd": "^3.53.0",`
`"@pankod/refine-core": "^3.78.0",`

Example:

	const { selectProps: someDataSelectProps } = useSelect<SomeData>({
		resource: 'someResource',
		fetchSize: 5,
		optionValue: 'id',
		optionLabel: 'displayName',
		queryOptions: {
			enabled: true,
			staleTime: Timer.FifteenMinutes
		}
	})

This will get you the correct data back, but in the network tab you will see 2 queries being made one without params and another one with correct pageSize params which are -> pageSize: 5

ex:

Req One: SomeData
Req Two: SomeData/page=0&pageSize=5

I'm a bit confused about why is there a fetchSize option if it fetches all data on initial render that exists anyway?

Clarification: If you use useList, with overridden pagination, it will work and make expected 1 query only

	const res = useList<SomeData>({
		resource: 'someResource',
		config: {
			pagination: {
				current: 1,
				pageSize: 100
			},
			filters: [
				{
					field: 'sort',
					operator: 'eq',
					value: 'NameAsc'
				}
			]
		},
		queryOptions: {
			enabled: true,
			staleTime: Timer.Hour
		}
	})
@vinclou
Copy link
Author

vinclou commented Oct 10, 2022

I figured what's causing this:

If u override queryOptions obj, the double fetch bug appears, removing it solves the problem

Yet it is an issue, as metadata select is pretty much stale data that doesn't change quite often. A long staleTime on metaData queries is preferable.

		queryOptions: {
			enabled: true,
			staleTime: Timer.Hour
		}

@aliemir aliemir added the bug Something isn't working label Oct 11, 2022
@aliemir aliemir changed the title useSelect Ignores fetchSize [BUG] useSelect Ignores fetchSize Oct 11, 2022
@alicanerdurmaz
Copy link
Member

@vinclou Thank you for the issue 🙏

We prioritized this bug and we will solve it as soon as possible.

@alicanerdurmaz
Copy link
Member

@vinclou Hi again, we solved the problem. We will merge fix today. Thanks for the issue 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants