【发布时间】:2016-08-20 01:22:10
【问题描述】:
我卡了一会儿,不知道哪里错了,请帮帮我
这是错误信息:
Warning: App(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.
Uncaught TypeError: inst.render is not a function
这是我的代码:
import React from 'react';
import ReactDOM from 'react-dom';
console.log('Start')
export class App extends React.Component{
constructor(props) {
super(props);
console.log('getInitialState');
return { status:true }
}
toggleState(){
this.setState({status: !this.state.status})
}
render() {
console.log('render');
return (
<div>
<h1 onClick={this.toggleState}>Hello</h1>
</div>
);
}
}
ReactDOM.render(<App name='Vipul' />,document.getElementById('app'));
【问题讨论】:
标签: reactjs ecmascript-6