-
Notifications
You must be signed in to change notification settings - Fork 242
ui: URL State hook revamp #4864
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
Conversation
|
🤖 Meticulous spotted visual differences in 3 of 494 screens tested: view and approve differences detected. Last updated for commit 7a4f17a. This comment will update as new commits are pushed. |
| const [groupBy, setStoreGroupBy] = useURLState<string[]>('group_by', { | ||
| defaultValue: [FIELD_FUNCTION_NAME], | ||
| alwaysReturnArray: true, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference between setting a default value like this i.e. using the defaultValue prop,
| const [groupBy, setStoreGroupBy] = useURLState<string[]>('group_by', { | |
| defaultValue: [FIELD_FUNCTION_NAME], | |
| alwaysReturnArray: true, | |
| }); | |
| const [groupBy, setStoreGroupBy] = useURLState<string[]>('group_by', { | |
| defaultValue: [FIELD_FUNCTION_NAME], | |
| alwaysReturnArray: true, | |
| }); |
and also doing it like the one a bit further in this file, like this:
| const [groupBy, setStoreGroupBy] = useURLState<string[]>('group_by', { | |
| defaultValue: [FIELD_FUNCTION_NAME], | |
| alwaysReturnArray: true, | |
| }); | |
| const [compareAbsolute = compareAbsoluteDefault, setCompareAbsolute] = | |
| useURLState('compare_absolute'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No technical difference, just an explicit way to set the default value right now.
But in the future, I'm thinking we should move away from this distributed (passing it while accessing the hook) default value usage to a more centralized usage by passing the default values in the URLStateProvider. So that the consuming hooks don't have to worry about the default state and also when a param is in the default state, we don't actually have to push it to the URL.
This will also help keep the URL to be a bit concise by only having non-default values.
yomete
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! just one inquisitive question.
Why?
navigateToarg to every hookuseStatelike API structure with for generic type supportIncludes:
Future Work: