在我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