[英]TypeError: default.a.createClass is not a function in React v16
sday.js sday.js
import React from 'react';
const sday= React.createClass({
render( ){
return (
<div>hello world</div>
);
}
})
export default sday;
index.js index.js
import React from 'react';
import ReactDOM from 'react-dom';
import registerServiceWorker from './registerServiceWorker';
import './index.css';
import App from './App';
import {sday} from './Component/example';
window.React= React;
ReactDOM.render(<sday/> , document.getElementById('root'));
registerServiceWorker();
I am trying to render sday
but I am getting an error of create class is not a function: 我正在尝试渲染
sday
但我收到一个create class错误不是函数:
TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createClass is not a function
TypeError:__WEBPACK_IMPORTED_MODULE_0_react ___ default.a.createClass不是一个函数
createClass
got removed in React 16 , which is why you get the error. 在React 16中删除了
createClass
,这就是为什么出现错误的原因。
If you would still like to use createClass
, you can use the standalone create-react-class package. 如果仍要使用
createClass
,则可以使用独立的create-react-class包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.