-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Tabs] Invalid value warning triggered when using React.lazy #29209
Comments
@iluvmemes would you be able to create a reproduction in a repo I could investigate locally? Having to add dependencies to see the error makes it somewhat hard to investigate. |
I have the same problem |
same problem while import use React.lazy, e.g.
error: fix: |
I've been trying to get a repo together to reproduce the problem per @michaldudak's request with lazy loading (we use that in our app). @remyzane we're already using suspense in our app and still receive the warnings. |
@remyzane was correct. It looks as though it happens when the contents of the actual tab is lazy loaded. @michaldudak here is a repo you can look at. |
This warning is caused by the code added as a fix for #26582. --- a/packages/mui-material/src/Tabs/Tabs.js
+++ b/packages/mui-material/src/Tabs/Tabs.js
@@ -357,9 +357,7 @@ const Tabs = React.forwardRef(function Tabs(inProps, ref) {
if (
process.env.NODE_ENV !== 'test' &&
!warnedOnceTabPresent &&
- tabMeta &&
- tabMeta.width === 0 &&
- tabMeta.height === 0
+ tab?.style?.display === 'none'
) {
tabsMeta = null;
console.error( It should cover the original case described in #26582 and prevent the warning from firing in this case. |
value
provided to the Tabs component is invalid. (Possible reoccurrence of #8489)
The regression in the codesandbox reproduction started between v5.0.0-beta.0 and v5.0.0-rc.0. What we did is the release of #27791. I assume that codesandbox triggers a layout change, that triggers the resize observer, that trigger |
Regarding looking at |
Does it mean that the tab underline indicator is at the wrong position? I have given it a try: yes. But thanks to #27791, it update it at the right position. |
Ok, as far as I can dive into this problem, this is a bug with React & Suspense. I cloned https://github.com/iluvmemes/MUI-29209, I added the Tabs.js locally and added a breakpoint when the warning triggers. When useEffect/useLayoutEffect run inside the Tabs, React still has It reminds me: facebook/react#14536. |
Ok, looks like it's a known bug with React 17.0.2 @eps1lon was already into it facebook/react#21510. I think that we can close this issue with the "external dependency" label. It supposed to be fixed in React 18: facebook/react#21510 (comment). |
Duplicate of #14077 |
For me this issue is still happening even after upgrading to "react": "^18.2.0", so could be something else as well? |
I'm also still experiencing this after upgrading to React 18.2.0 and MUI 5.5.3. |
@mikkopori, @BryanAPEX thanks for letting us know. I'm reopening the issue. |
v5.0.4
Much like the description in #8489, when using dynamic data to generate tabs and their contents, I receive the error:
However, this only occurs once in our app after a hard refresh. I have reproduced this in a code sandbox however, it seems that there may be some caching with codesandbox.io that prevents it from happening.
In order to reproduce it in Codesandbox, you will need to add or remove a dependency such as lodash or something from the fork.
https://codesandbox.io/s/sparkling-grass-sfidi?file=/src/TabIssue.jsx
The text was updated successfully, but these errors were encountered: