-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
ReferenceField error when logging out #6733
Comments
The codesandbox you linked is empty. Can you please fork & tweak the simple example to show the issue? Thanks! |
Sorry, somehow I pasted the wrong link. It's fixed in the main issue body and here is the link for quick reference as well. CodeSandbox example: https://codesandbox.io/s/react-admin-referencefield-error-ur8wr |
I would add one more thing I noticed in the CodeSandbox version that I'm not experiencing locally but might help. The first time the CodeSandbox boots up, when you login it will display the error As I mentioned in the initial post, I get that error locally but only on logout. I thinking perhaps the differences are due to the authProvider in the CodeSandbox is a simulation and returns far faster than my Amplify authProvider I'm using in our project. Could indicate a race condition of some kind. Either way I think it's related to the same issue and hopefully I can help find a fix for it. |
Reproduced. Thanks |
What you were expecting:
Log out of react-admin without errors
What happened instead:
When logging out, errors are thrown to the console.
Uncaught Error: You must declare a <Resource name="users"> in order to use a <ReferenceField reference="users">
The above error occurred in the <ReferenceField> component
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
Steps to reproduce:
Create a component on the dashboard that uses a ReferenceField. Logout and the errors will appear in your console.
I reproduced in CodeSandbox but for some reason it doesn't produce the first one ("Uncaught Error: You must declare a ..."), which the second one is referencing ("the above error occured in the component").
Related code:
I think it may be related to this issue - #5576
https://codesandbox.io/s/react-admin-referencefield-error-ur8wr
Other information:
It's potentially related to the redux issues mentioned in issue 5576 above, the dreadful "Stale Props and "Zombie Children".
What seems to be happening is that upon logout the dashboard is re-rendered due to some state changing. In the process of the dashboard re-rending the redux store is cleared before the ReferenceField is rendered. Then when the ReferenceField attempts to pull its data, the redux store is empty and it can't find the resource.
Environment
The text was updated successfully, but these errors were encountered: