Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ES6,React-如何在动态生成的类中设置类名?_Javascript_Reactjs_Ecmascript 6_Dynamic Class Creation - Fatal编程技术网

Javascript ES6,React-如何在动态生成的类中设置类名?

Javascript ES6,React-如何在动态生成的类中设置类名?,javascript,reactjs,ecmascript-6,dynamic-class-creation,Javascript,Reactjs,Ecmascript 6,Dynamic Class Creation,我有一个生成器方法,它用注入的道具包装一个类,我想将类名设置为与包装的类相同。我如何做到这一点?(如果需要,只需忽略流输入) const buildComponentWithInjectedProps= (SubjectClass,injectedProps)=>{ 返回类扩展了React.PureComponent{ /*set classname=主题类的名称*/ render(){ 返回(); } }; }; 调试ReactJS需要类名吗 可能会有帮助。不,是真实的类名 const bui

我有一个生成器方法,它用注入的道具包装一个类,我想将类名设置为与包装的类相同。我如何做到这一点?(如果需要,只需忽略流输入)

const buildComponentWithInjectedProps=
(SubjectClass,injectedProps)=>{
返回类扩展了React.PureComponent{
/*set classname=主题类的名称*/
render(){
返回();
}
};
};

调试ReactJS需要类名吗


可能会有帮助。

不,是真实的类名
const buildComponentWithInjectedProps =
  (SubjectClass, injectedProps) => {
    return class extends React.PureComponent {
      /*set classname=name of SubjectClass*/
      render() {
        return (<SubjectClass {...injectedProps} {...this.props} />);
      }
    };
  };