我試圖刪除一個<Table>
數據。我正在做的是,選擇<Table>
的單行並按下Delete
按鈕(自定義)。並且正在觸發刪除功能。assembliesnetDidUpdate()沒有被調用
數據在服務器端被刪除,但UI未更新。 這裏是代碼:
export default class DeleteUserForms extends Component{
constructor(props) {
super(props);
this.state = {value: 1};
this.data = this.props.selectedValue;
this.handleDeletedata=this.handleDeletedata.bind(this);
}
handleDeletedata(event){
event.preventDefault();
console.log('Data before delete function call');
console.log(this.data);
this.props.dispatch(deleteUser(this.data));
// this.props.close(event)
}
componentWillUpdate(){
console.log('COMPONENT WILL UPDATEEEEEEEEEEEEEEEEE');
this.props.dispatch(getUserRole())
}
// componentDidMount(){
// console.log('COMPONENT DID MOUNT');
// // this.props.close();
// }
componentDidUpdate(){
console.log('COMPONENT DID UPDATEEEEEEEEEEEEEEEEEEEEE');
// this.props.close();
}
render(){
return(
<form onSubmit={this.handleDeletedata}>
<MuiThemeProvider muiTheme={muiThemedrpdown}>
<div>
Do you really want to delete the record for {this.props.selectedValue.name}?
</div>
</MuiThemeProvider>
<MuiThemeProvider muiTheme={muiThemebtn}>
<div>
<RaisedButton label="Yes" primary={true} type="submit" className="btndiv"
/>
<RaisedButton label="No" primary={true}
onClick={this.props.close} className="btndiv" />
</div>
</MuiThemeProvider>
</form>
);
}}
這裏也是我想要的數據已被刪除後,關閉模式。但componentDidUpdate()
方法未被調用。 請建議
你有什麼錯誤嗎? –
控制檯沒有錯誤 – NDeveloper
你可以發佈'deleteUser(this.data)'觸發的reducer代碼嗎? –