Skip to content

Conversation

@Zetazzz
Copy link
Collaborator

@Zetazzz Zetazzz commented Aug 3, 2023

Luca found getter in useQuery(['rpcEndpoint', getter], can only be serialized as a null. So there's no difference between multi-chain endpoints, when switching between chains things wouldn't be changed automatically. So Luca suggested adding an extra key for better react query usage, like:

export const useRpcEndpoint = <TData = string | HttpEndpoint>({
    getter,
    options,
    extraKey
}: UseRpcEndpointQuery<TData>) => {
...useQuery(['rpcEndpoint', getter, extraKey],
}

@pyramation
Copy link
Collaborator

Would be nice to use a better option name, besides that LGTM!

@Zetazzz
Copy link
Collaborator Author

Zetazzz commented Aug 5, 2023

I reconsidered this.

I removed flag. If user left extraKey null, the behavior of the function remain the same query key as before('["rpcEndpoint",null]'). If user input an extraKey, user will get '["rpcEndpoint", "extraKey"]'.

@Zetazzz
Copy link
Collaborator Author

Zetazzz commented Aug 9, 2023

There's a requirement from @marslavish :
some of customized hooks should have extraKey too. So I added needExtraQueryKey option in ReactQuery option, but currently, only useEndpoint is changed into this logic. I'll make another PR on other customized hooks.

@Zetazzz Zetazzz merged commit 250952c into main Aug 9, 2023
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

Successfully merging this pull request may close these issues.

3 participants