Reactjs 如何使用withStyles返回react组件?

Reactjs 如何使用withStyles返回react组件?,reactjs,material-ui,react-with-styles,Reactjs,Material Ui,React With Styles,这里的问题不是如何导出,而是如何在注入css的情况下返回React对象 我正在努力实现这样的目标: return ( withStyles(this.props.style)(<Component {...params}/>) ); return(带有样式(this.props.style)(); 其中意图是返回组件,使用with styles设置所有CSS,并将其样式注入名为stylewith styles的属性中,HOC接受类/函数并返回修饰类/函数。这就是为什么我们不能传递

这里的问题不是如何导出,而是如何在注入css的情况下返回React对象

我正在努力实现这样的目标:

return ( withStyles(this.props.style)(<Component {...params}/>) );
return(带有样式(this.props.style)();

其中意图是返回组件,使用with styles设置所有CSS,并将其样式注入名为style
with styles
的属性中,HOC接受类/函数并返回修饰类/函数。这就是为什么我们不能传递这些组件实例(
在引擎盖下创建/返回对象)

考虑到这一点以及JSX要求组件名称以大写字母开头的要求,我们接下来可以做:

const StyledComponent = withStyles(this.props.style)(Component);
return <StyledComponent {...params} />;
constyledComponent=withStyles(this.props.style)(组件);
返回;

带有样式
HOC接受类/函数并返回修饰过的类/函数。这就是为什么我们不能传递这些组件实例(
在引擎盖下创建/返回对象)

考虑到这一点以及JSX要求组件名称以大写字母开头的要求,我们接下来可以做:

const StyledComponent = withStyles(this.props.style)(Component);
return <StyledComponent {...params} />;
constyledComponent=withStyles(this.props.style)(组件);
返回;