SSR error -- extra attributes from the server: tabindex #698
-
When developing with Gatsby using the DEV_SSR flag, the following warning shows in the browser console:
I think this sort of error occurs when there's a mismatch between what is server-side rendered vs. what is rendered in the browser after React hydration. If there's a need for a basic github repo with Gatsby demonstrating the issue just let me know, since this isn't reproducible in codepen. This is with |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
thanks for the feedback and reporting. it's indeed like you say related to that some Media Chrome elements get new attributes when they are connected to the DOM which are not there on the server. it's nothing to worry about. the error in your post can easily be fixed by setting the tabIndex={-1} on the video element. however other elements will also also be affected. |
Beta Was this translation helpful? Give feedback.
-
Thanks you @luwes for the workaround of adding
I tried the same workaround and added those attributes to the
which then resulted in yet another new error
From what I understand, this kind of error will cause React to re-render the page, which is fairly consequential. I'm using (RTK Query)[https://redux-toolkit.js.org/rtk-query/overview], which caches data from the server, but with a re-render the cache will be wiped, the server will be queried again, and dynamic UI elements on the page will flash between states while they wait for server data. |
Beta Was this translation helpful? Give feedback.
-
yes this is expected at the moment. are you sure it will cause a re-render? I don't think it does. if React is forced to do a re-render from a mismatch it logs another warning saying it. we use SSR'd React components on the landing page as well https://www.media-chrome.org/ we have the warnings in dev but I don't think it's a major concern if no re-render is triggered |
Beta Was this translation helpful? Give feedback.
-
I've created a repo to reproduce the issue: https://github.com/ShaunDychko/demo-mediachrome-ssr-error To reproduce
While the error shows in the browser console, I was not able to demonstrate that React has to re-render. |
Beta Was this translation helpful? Give feedback.
-
thanks for providing an example to reproduce. appears there is also a special property |
Beta Was this translation helpful? Give feedback.
-
@luwes What do we need to do to close this one? Has it been partially solved by the move to properties? Do we need to document this somewhere? |
Beta Was this translation helpful? Give feedback.
-
I'll move it to a discussion. there's nothing for us to do but make users aware this is expected behavior. nope, the tabIndex property is reflected to the attribute. yes maybe in the docs in https://www.media-chrome.org/docs/en/react |
Beta Was this translation helpful? Give feedback.
yes this is expected at the moment. are you sure it will cause a re-render?
I don't think it does. if React is forced to do a re-render from a mismatch it logs another warning saying it.
we use SSR'd React components on the landing page as well https://www.media-chrome.org/
https://github.com/muxinc/media-chrome/blob/main/docs/src/pages/landing/components/player-panel.tsx
we have the warnings in dev but I don't think it's a major concern if no re-render is triggered