-
-
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
[RFR] Convert GET_MANY accumulate saga to hooks #3550
Conversation
divides the number of renders by 2
…ManyAccumulate Closes #3552
a77e902
to
d38f2cc
Compare
Switching to RFR |
oops, sorry, I missed a side effect, back to WIP |
Well, that's in |
@@ -144,7 +144,11 @@ export const ReferenceFieldView = ({ | |||
} | |||
if (error) { | |||
return ( | |||
<Error aria-errormessage="Error" color="error" fontSize="small" /> | |||
<Error | |||
aria-errormessage={error.message ? error.message : error} |
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.
Shouldn't we translate this error ?
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.
Ideally, yes. In a future PR? I'd like to have this pr merged quickly to release a new alpha soon.
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.
Awesome!
Using a hook in
ReferenceField
allows to handle corner cases that were impossible to deal with using sagas. Most notably,ReferenceField
now works properly when thedataProvider
fails or returns nothing for theGET_MANY
call.This is mostly a refactoring with few visible changes for the end user, labeled 'NEW' below.
useGetMany
hook based oncrudGetManyAccumulate
action logicuseGetMany
useReference
<ReferenceField>
if thedataProvider
call fails or returns nothing<ReferenceField>
if thedataProvider
failsuseReferenceArrayFieldController
Use the new hook in(too long, to be done in another PR)ReferenceArrayInputController
Closes #3552, #3451, #2388, #854.
To be done in another PR:
useGetMatching
hook based oncrudGetMatchingAccumulate
action logicuseGetMatching
ReferenceInput
,ReferenceArrayInput
,SelectArrayInput
andSelectInput
accumulate
sagaThis change is backwards compatible with the
accumulate
saga, i.e. dispatchingcrudGetManyAccumulate
actions still works with the saga. The newuseGetMany
hook does not dispatch such actions.