Material-ui: withTheme not working with REACT 16

Created on 14 Oct 2017  路  2Comments  路  Source: mui-org/material-ui

Expected Behavior

Am able to use withTheme in my React 16 application

Current Behavior

When using withTheme from [email protected] with React 16, React gives the following warning, which is fatal to the execution of my app.

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.

Steps to Reproduce

Here is an example of how I am using withTheme:

const MyComponent = props => {
// use props.theme.palette.text.primary
};
export default withTheme(MyComponent);

Environment

Issue did not exist when using withTheme with React 15. Issue occurs post-upgrade of React.

| Tech | Version |
|--------------|---------|
| Material-UI | 1.0.0-beta.16 |
| React | [email protected], [email protected] |
| browser | Chrome Version 61.0.3163.100 |

question

Most helpful comment

The signature changed:

-export default withTheme(MyComponent);
+export default withTheme()(MyComponent);

All 2 comments

The signature changed:

-export default withTheme(MyComponent);
+export default withTheme()(MyComponent);

Thank you. Must have been brought in with my npm update. Sorry I missed it.

Was this page helpful?
0 / 5 - 0 ratings