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

includeAllParams not working #268

Open
pdme opened this issue Jun 7, 2023 · 1 comment
Open

includeAllParams not working #268

pdme opened this issue Jun 7, 2023 · 1 comment

Comments

@pdme
Copy link

pdme commented Jun 7, 2023

I'm using this lib together with next-query-params.

I have a QueryParamConfigMap which I pass to useQueryParams(queryParamConfigMap, { includeAllParams: true })

The return value however does not include query params that are not included in the config.

@alioguzhan
Copy link

Same here. I both configured this on provider and hook levels but it does not include the params does not exists in the config map.

I am generating some filter inputs based on some remote data. I have no idea about the names and count.

As a workaround, I am building a second param config on the fly and merging it with the existing one:

const ConfigForRemote = remoteData.attributes.reduce((acc, attr) => {
    return { ...acc, [attr.code]: withDefault(StringParam, undefined) };
  }, {} as any);

const [params, setParams] = useQueryParams<typeof MyParamConfig>({ ...MyParamConfig, ...ConfigForRemote });

The above is working so far.

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

2 participants