-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Failed prop type: Invalid prop children
supplied to ThemeProvider
, expected a ReactNode.
#45432
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Can you share the repo? I don't recall that the |
Good afternoon, here is an example. The project is already built and located in the "public" folder. You can launch index.html. |
As you can see from the const theme = (0,_mui_material__WEBPACK_IMPORTED_MODULE_2__["default"])();
const App = () => {
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mui_material__WEBPACK_IMPORTED_MODULE_3__["default"], { theme: theme, children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { children: "1" }) }));
};
const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot)(document.getElementById("app"));
root.render((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(App, {})); It's common to remove PropTypes from production build, please try to use https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @bartplay2499 How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The thing is, this is not a production build, it's a development build, and it shows a bunch of warnings during development. In version 5.x.x, this behavior did not occur. All other settings and libraries remained the same. Only MUI was updated. package.json
webpack.config.development.js
|
Good afternoon, are there any updates on this issue? |
It could be this PR that introduces the bug. cc @DiegoAndai @Janpot Do you think the PR is the root cause of this? |
@bartplay2499 When I do the following in your project import PropTypes from 'prop-types';
import * as React from 'react';
import { createRoot } from 'react-dom/client';
const Foo: React.ComponentType<{ children: any }> = ({ children }) => {
return <div>{children}</div>;
};
Foo.propTypes = {
children: PropTypes.node.isRequired,
};
export const App: React.FC = () => {
return (
<Foo>
<div>2</div>
</Foo>
);
};
const root = createRoot(document.getElementById('app')!);
root.render(<App />); it looks like it has the same problem. It doesn't look like it's related specifically to Perhaps you can strip it down even further, to remove all unnecessary dependencies and webpack configuration? |
Good afternoon, I tried to clean up the project by removing all dependencies and keeping only React, TypeScript, @mui, and Webpack. However, as soon as I try to use components from MUI, it still shows warnings. |
I'm seein' the same warnings with the following mui packages installed:
|
@peterszu What React version are you using? Please provide a reproducible repository that we can take a look. |
Found the root cause, it's from TLDR;Material UI v6 and v7 bump react-is v18: At runtime, a React node is DetailsThe children prop has
react-is v16: var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
function isElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
} react-is v19: var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), // 🚨 this is where issue occurs
exports.isElement = function (object) {
return (
"object" === typeof object &&
null !== object &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}; The propValue of children is This error depends on the package manager because several versions of
|
Steps to reproduce
Current behavior
A lot of warnings are shown in the console, even with a minimal application like this:
Expected behavior
There should be no warnings.
Context
No response
Your environment
No response
Search keywords: children, ReactNode, Invalid prop
The text was updated successfully, but these errors were encountered: