-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Allow disabling store persistence of the list parameters #9019
Conversation
@@ -88,15 +88,23 @@ export const useListParams = ({ | |||
const location = useLocation(); | |||
const navigate = useNavigate(); | |||
const [localParams, setLocalParams] = useState(defaultParams); | |||
const [params, setParams] = useStore(storeKey, defaultParams); | |||
const [params, setParams] = useStore( | |||
storeKey || `${resource}.listParams`, |
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.
if storeKey
is false, this will still use the store. Can you add a comment to explain what's the rationale?
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.
We can't disable a hook, so although we still read the store, its values are not used later in the code
@@ -111,7 +119,10 @@ export const useListParams = ({ | |||
() => | |||
getQuery({ | |||
queryFromLocation, | |||
params: disableSyncWithLocation ? localParams : params, | |||
params: | |||
disableSyncWithLocation || disableSyncWithStore |
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.
I think you must also dd the check for disableSyncWithStore
in changeParams
L146, and anywhere else the setParams
may be called.
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.
changeParams
does not call setParams
Problem
For one-off lists (e.g. in dashboards),
<ListBase>
does the fetching and puts the data in a<ListContext>
, so it’s fine.But as it uses the store by default, a list for a given resource will be affected by the actions of the user in other lists of the same resource.
It’s possible to specify a different
storeKey
to avoid that, but it’s silly to have to define a store key when what I want is to disable the use of the store altogether.It’s also possible to use
disableSyncWithLocation
, but the name of that prop isn’t clearly related to the store.Solution
Allow to set
storeKey
tofalse
to disable the store altogether