What you were expecting:
I declared myresource and when I was on 3.3.3, my page worked as expected. (but useQueryWithStore returned a null total.
What happened instead:
Now that I upgraded to 3.4.0, useQueryWithStore returns the right total but on first page load (custom route with ReferenceInput) I have an error :
You must add <Resource name="souscommanderie" /> as child of <Admin> to use "myresource" in a reference
at useGetMatchingReferences.js:68
at useSelectorWithStoreAndSubscription (useSelector.js:27)
at useSelector (useSelector.js:103)
at useGetMatchingReferenceSelector (useGetMatchingReferences.js:78)
at useGetMatchingReferences.js:25
at useReferenceInputController (useReferenceInputController.js:85)
at ReferenceInput (ReferenceInput.js:134)
at renderWithHooks (react-dom.development.js:14797)
at mountIndeterminateComponent (react-dom.development.js:17409)
at beginWork (react-dom.development.js:18489)
Steps to reproduce:
I'll make a sandbox tomorrow and try to figure out which version introduced the regression.
Other information:
Environment
Error: Cannot fetch a reference to "myresource" (unknown resource).
You must add <Resource name="myresource" /> as child of <Admin> to use "myresource" in a reference
at ? (/static/js/0.chunk.js:265990:13)
at useSelectorWithStoreAndSubscription(/static/js/0.chunk.js:352587:23)
at useSelector(/static/js/0.chunk.js:352663:12)
at useGetMatchingReferenceSelector(/static/js/0.chunk.js:266000:73)
at ? (/static/js/0.chunk.js:265947:28)
at useReferenceInputController(/static/js/0.chunk.js:266349:101)
at ReferenceInput(/static/js/0.chunk.js:303153:196)
at renderWithHooks(/static/js/0.chunk.js:335941:22)
at mountIndeterminateComponent(/static/js/0.chunk.js:338553:17)
at beginWork(/static/js/0.chunk.js:339633:20)
at HTMLUnknownElement.callCallback(/static/js/0.chunk.js:321333:18)
at HTMLUnknownElement.sentryWrapped(/static/js/0.chunk.js:189205:17)
at Object.invokeGuardedCallbackDev(/static/js/0.chunk.js:321382:20)
at invokeGuardedCallback(/static/js/0.chunk.js:321435:35)
at beginWork$1(/static/js/0.chunk.js:344199:11)
at performUnitOfWork(/static/js/0.chunk.js:343163:16)
at workLoopSync(/static/js/0.chunk.js:343139:26)
at performSyncWorkOnRoot(/static/js/0.chunk.js:342757:13)
at ? (/static/js/0.chunk.js:332275:28)
at unstable_runWithPriority(/static/js/0.chunk.js:363546:16)
at runWithPriority$1(/static/js/0.chunk.js:332221:14)
at flushSyncCallbackQueueImpl(/static/js/0.chunk.js:332270:11)
at flushSyncCallbackQueue(/static/js/0.chunk.js:332258:7)
at scheduleUpdateOnFiber(/static/js/0.chunk.js:342200:13)
at dispatchAction(/static/js/0.chunk.js:336778:9)
at ? (/static/js/0.chunk.js:281473:34)
at ? (/static/js/0.chunk.js:268489:15)
at step(/static/js/0.chunk.js:268420:19)
at Object.next(/static/js/0.chunk.js:268350:14)
at fulfilled(/static/js/0.chunk.js:268304:24)
I'm also facing this issue. The first time that I open a page using the custom route, it works. But if I refresh the page, I get this error.
You can easily simulate this if you add the simple code below inside the Configuration page from the demo (you can change the fields with any resource that you've in your app).
<Create resource="competitions" basePath="/competitions" >
<SimpleForm>
<ReferenceInput label="Challenge" reference="challenges" source="id">
<AutocompleteInput optionText="task" />
</ReferenceInput>
</SimpleForm>
</Create>
Thanks for reporting this. If you are able to illustrate the bug or feature request with an example, please provide a sample application by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple).
@djhi
You can reproduce the issue by clicking on the Configuration menu (Top Right), then refreshing the browser inside the sandbox.
CodeSandbox link: https://codesandbox.io/s/billowing-wood-vm528
Also, accessing this route Configuration Route directly inside the sandbox browser, you'll get the same issue.
Reproduced. Thanks