這裏是形式不能通過國家行動創造者陣營
<PostBody>
<Input value={this.state.title} onChange={(value) => this.onChangeTitle(value)} ref="titleInput" type="text" id="title" name="title" placeholder="Post Title" />
<TextArea value={this.state.body} onChange={(value) => this.onChangeBody(value)} ref="bodyInput" id="body" name="body" placeholder="Post Content" />
<ToolBar>
<Button disabled={!this.props.ptitle || !this.props.pbody} onClick={this.props.doSave(this.state)}>Save</Button>
<BackLink to="/posts">Cancel</BackLink>
<div style={{float:'left', marginTop:'10px'}}>
{backBtn}
</div>
</ToolBar>
</PostBody>
這裏是我打電話的動作製作功能
doSave: (state) => {
dispatch(savePostAction(state));
},
但這導致錯誤
warning.js:36 Warning: setState(...): Cannot update during an existing state transition (such as within
render
or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved tocomponentWillMount
.
並且正在無限次地導致
Uncaught RangeError: Maximum call stack size exceeded
我甚至試着在點擊時調用另一個函數,然後通過傳遞該函數的狀態來調用doSave()。仍然得到相同的錯誤。請幫忙。
謝謝。這解決了我的問題。 :) – AeJey