Skip to content
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

disableAuthentication throws an error for <Show/> component and has no effect #7829

Closed
arnaudvergnet opened this issue Jun 15, 2022 · 1 comment · Fixed by #7837
Closed

Comments

@arnaudvergnet
Copy link
Contributor

What you were expecting:
disableAuthentication should work for all components.

What happened instead:
disableAuthentication does not work for <Show/> components. It throws the following error in the console:

React does not recognize the `disableAuthentication` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `disableauthentication` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Steps to reproduce:

  • Implement an authProvider
  • Add the disableAuthentication prop to a <Show/> component.
  • Try to access the show page
  • Be redirected to the login page instead of the show page

Related code:
Here is a sandbox forked from the simple v4 example: https://codesandbox.io/s/stupefied-volhard-zeedw3

Changes:

  • Post list, show, edit and create view modes, as well as Comments list and show all have the disableAuthentication prop.
  • Removed the mobile friendly UI for easier testing

How to trigger the issue:

  • Logout then go back to the index page: the posts list should display.
  • Try to click on a post to show it. It works because it uses the useShowController instead of the <Show/> component.
  • Try to edit or create new posts. It works.
  • Try to open the comments list and click on show for one of the items. It redirects to the login page because this view uses the <Show/> component.

Environment

  • React-admin version: 4.1.3
  • Last version that did not exhibit the issue (if applicable):
  • React version: 17.0.1
  • Browser: Firefox
  • Stack trace (in case of a JS error):
Warning: React does not recognize the `disableAuthentication` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `disableauthentication` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
div
./node_modules/@emotion/react/dist/emotion-element-cbed451f.browser.esm.js/withEmotionCache/<@https://zeedw3.sse.codesandbox.io/index.bundle.js:590:66
./node_modules/ra-ui-materialui/dist/esm/index.js/kr<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111181:825
./node_modules/ra-core/dist/esm/index.js/le<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110598:5063
./node_modules/ra-core/dist/esm/index.js/wa<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110598:33648
./node_modules/ra-core/dist/esm/index.js/Bv<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110598:33876
./node_modules/ra-ui-materialui/dist/esm/index.js/Ek<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111181:2877
CommentShow
Routes@https://zeedw3.sse.codesandbox.io/index.bundle.js:148046:7
./node_modules/ra-core/dist/esm/index.js/ce<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110591:8079
./node_modules/ra-core/dist/esm/index.js/Jn<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110591:8263
Routes@https://zeedw3.sse.codesandbox.io/index.bundle.js:148046:7
ErrorBoundary@https://zeedw3.sse.codesandbox.io/index.bundle.js:140349:37
div
main
div
div
./node_modules/@emotion/react/dist/emotion-element-cbed451f.browser.esm.js/withEmotionCache/<@https://zeedw3.sse.codesandbox.io/index.bundle.js:590:66
./node_modules/ra-ui-materialui/dist/esm/index.js/Hc<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111167:72144
__WEBPACK_DEFAULT_EXPORT__
div
Routes@https://zeedw3.sse.codesandbox.io/index.bundle.js:148046:7
./node_modules/ra-core/dist/esm/index.js/lo<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110591:3978
Routes@https://zeedw3.sse.codesandbox.io/index.bundle.js:148046:7
./node_modules/ra-core/dist/esm/index.js/Hn<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110591:6453
./node_modules/ra-ui-materialui/dist/esm/index.js/eD<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111204:7423
InnerThemeProvider@https://zeedw3.sse.codesandbox.io/index.bundle.js:40137:70
ThemeProvider@https://zeedw3.sse.codesandbox.io/index.bundle.js:39850:7
ThemeProvider@https://zeedw3.sse.codesandbox.io/index.bundle.js:40159:7
./node_modules/ra-ui-materialui/dist/esm/index.js/Qc<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111167:82114
./node_modules/ra-core/dist/esm/index.js/kn<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:56098
./node_modules/ra-core/dist/esm/index.js/Ho<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:8289
./node_modules/ra-core/dist/esm/index.js/At<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:8863
Router@https://zeedw3.sse.codesandbox.io/index.bundle.js:147984:7
No@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:767
./node_modules/ra-core/dist/esm/index.js/ps<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:1826
./node_modules/ra-core/dist/esm/index.js/Uo<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:1256
./node_modules/ra-core/dist/esm/index.js/jo<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:1393
QueryClientProvider@https://zeedw3.sse.codesandbox.io/index.bundle.js:146044:16
./node_modules/ra-core/dist/esm/index.js/zo<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:7050
./node_modules/ra-core/dist/esm/index.js/uo<@https://zeedw3.sse.codesandbox.io/index.bundle.js:110590:56811
./node_modules/ra-ui-materialui/dist/esm/index.js/oD<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111204:7855
./node_modules/react-admin/dist/esm/index.js/M<@https://zeedw3.sse.codesandbox.io/index.bundle.js:111755:498
@antoinefricker
Copy link
Contributor

antoinefricker commented Jun 15, 2022

Reproduced! Thanks for reporting this so precisely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants