2016-08-23 6 views
1

나는 내 프로젝트에 + reactredux-form를 사용redux-form resetForm()이 완료되었음을 어떻게 알 수 있습니까?

//My components 
<button type="submit" className="btn btn-primary" onClick={this.getBuildingList.bind(this)}>Search</button> 
<button type="button" onClick={this.resetBuildForm.bind(this)}>Reset</button> 

//resetBuildingForm function 
resetBuildingForm(){ 
    let { dispatch, resetForm, list } = this.props; 
    resetForm(); 
    //when I resetForm, I want to search again 
    this.getBuildingList(); 
} 

내가 resetForm 때, 나는 다시 검색 할,하지만 난 REDUX-형태로 상태를 얻을 때, 나는 상태가 오래 얻을 수 있지만, 새로운 것이 아니다, 어떻게 할 수 언제 resetForm 이벤트가 완료되고 상태가 업데이트되는지 압니까?

답변

0

양식이 dirty에서 pristine으로 변경 될 때들을 수 있습니다.

componentDidUpdate(prevProps) { 
    if(this.props.pristine && !prevProps.pristine) { 
    // we just reset 
    this.getBuildingList() 
    } 
} 

그런 다음 this.props.resetForm()을 호출하여 재설정을 시작할 수 있습니다.

+0

대단히 감사합니다. – Liaoyf

1

나를 좋아하는 사람에게 도움이 될 수 있습니다. reduxForm 버전 6 이후로 this.props.resetForm()은 이미 this.props.reset()으로 변경되었습니다.

here을 참조하십시오.

관련 문제