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

[feature] useUrlState 支持嵌套对象 #2205

Open
Darcrandex opened this issue May 30, 2023 · 3 comments
Open

[feature] useUrlState 支持嵌套对象 #2205

Darcrandex opened this issue May 30, 2023 · 3 comments
Labels
enhancement Improvement or optimization v4

Comments

@Darcrandex
Copy link

目前 query-string 的嵌套得这么写 nesting,有点麻烦啊;能不能考虑改成使用 qs ?

@liuyib
Copy link
Collaborator

liuyib commented May 30, 2023

query-string 换成 qs 是个破坏性更改,parseOptions, stringifyOptions 配置项将变得不一样。可以考虑提供个参数,允许用户指定内部使用的 parse, stringify 函数,这样不会引入破坏性更改,比如:

import qs from 'qs';

const [state, setState] = useUrlState(
  { ids: ['1', '2', '3'] },
  {
    parse: qs.parse,
    stringify: qs.stringify,
  },
);

cc @hchlq 你觉着呢?

@hchlq
Copy link
Collaborator

hchlq commented May 30, 2023

感觉可以,自定义 parse 和 stringify,不过 v4 可以做更改

@andyyxw
Copy link

andyyxw commented Dec 6, 2023

query-string 换成 qs 是个破坏性更改,parseOptions, stringifyOptions 配置项将变得不一样。可以考虑提供个参数,允许用户指定内部使用的 parse, stringify 函数,这样不会引入破坏性更改,比如:

import qs from 'qs';

const [state, setState] = useUrlState(
  { ids: ['1', '2', '3'] },
  {
    parse: qs.parse,
    stringify: qs.stringify,
  },
);

cc @hchlq 你觉着呢?

@liuyib 期待这个功能,同样遇到了嵌套对象问题

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

No branches or pull requests

4 participants