我试图删除一个<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代码吗? –