简体   繁体   English

TypeError:default.a.createClass不是React v16中的函数

[英]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.

相关问题 React v16 hydrate 和 renderToNodeStream 与 render 和 renderToString - React v16 hydrate and renderToNodeStream vs render and renderToString 如何在没有构建过程的情况下使用React v16 - How to use React v16 without a build process 如何在React v16中手动调用自定义PropType验证器 - How to manually call custom PropType validators in React v16 React v16 – 通过包装组件将 ref 从子级传递给父级 - React v16 – pass ref from child to parent through a wrapper component Render.js文件中的“未捕获的TypeError:React.createClass不是函数”(电子应用程序) - “Uncaught TypeError: React.createClass is not a function” in Render.js file (electron app) undefined不是一个函数(评估React.createClass) - undefined is not an function (evaluating React.createClass) 得到错误:“react.createclass不是函数” - Getting error: “react.createclass is not a function” React .createClass()滚动到ref:scrollIntoView不是函数 - React .createClass() scroll to ref: scrollIntoView not a function Webpack构建React.createClass不是一个函数 - Webpack build React.createClass is not a function Excel加载项:Office for Mac v16中的deleteAllDataValuesAsync之后,addRowsAsync不起作用 - Excel Add-In: addRowsAsync does not work after deleteAllDataValuesAsync in Office for Mac v16
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM