在我reactjs程序,我这样做:reactJS componentWillMount之后运行呈现方法
constructor(props) {
super(props);
this.state = {
myTasks: tasksData,
processes: []
};
}
componentWillMount() {
fetch('http://localhost:9000/dashboard/processes')
.then(function (response) {
return response.json()
}).then(function (json) {
this.setState({processes: json});
}.bind(this)).catch(function (ex) {
console.log(ex)
});
}
问题是渲染方法运行bevor这和JSON数据是不是有正确的bevor表呈现
<BootstrapTable
react- data={this.state.processes}
search={true}
options={options}
striped hover condense
pagination={true}>
<TableHeaderColumn width='200' dataField='process' searchable={true} isKey><T value="dashboard.processes.process"/></TableHeaderColumn>
<TableHeaderColumn width='100' dataField='status'><T value="dashboard.processes.status"/></TableHeaderColumn>
<TableHeaderColumn width='100' dataField='progress' dataFormat={progressBarFormatter}><T value="dashboard.processes.progress"/></TableHeaderColumn>
<TableHeaderColumn width='100' dataField='deadline'><T value="dashboard.processes.deadline"/></TableHeaderColumn>
</BootstrapTable>
,所以我得到这个错误:
类型错误:在TableBody.eval无法读取的不确定 财产 '过程'(在./node_modules/react-bootstrap EVAL -table/lib/TableBody.js(http://localhost:8080/bundle.js:3702:1),:199:32) at Array.map(native) at TableBody.eval(eval at ./node_modules/react-bootstrap-table/lib/TableBody.js(http://localhost:8080/bundle.js:3702:1) ):198:47) at Table.map(native) at TableBody.render(eval at ./node_modules/react-bootstrap-table/lib/TableBody.js(http://localhost:8080/bundle.js:3702:1),:197:39) at TableBody .render(EVAL在./node_modules/react-proxy/modules/createPrototypeProxy.js(http://localhost:8080/bundle.js:5252:1):46:30) 在EVAL(在./node_modules/react-dom/lib/ReactCompositeComponent.js的eval(http://localhost:8080/bundle.js:4238:1), :798:21) at measureLifeCyclePerf(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js(http://localhost:8080/bundle.js:4238:1),:77:12) at Re actCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext(在./node_modules/react-dom/lib/ReactCompositeComponent.js的eval(http://localhost:8080/bundle.js:4238:1):797:25) 在ReactCompositeComponentWrapper._renderValidatedComponent(EVAL在./node_modules/react-dom/lib/ReactCompositeComponent.js( http://localhost:8080/bundle.js:4238:1),:824:32)
我该如何解决这个问题?
你能告诉我怎么会是什么样子? – Felix
当然,但是您必须更新您的帖子来解释dashboard.processes.process是什么,它不清楚仪表盘引用的是什么。这些应该可能是引用你的状态,而不是一些未更改的变量,直到你的状态被更新。 –
你的意思是只是一个翻译部分,工作正常。 – Felix