报错:
Modal: isMounted is deprecated. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.
class NewGateway extends React.Component {
constructor(props) {
super(props);
this.state = {errmsg: '', selectedValue: '2'};
// This binding is necessary to make `this` work in the callback
this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
this.setState({selectedValue: event.target.value});
}
handleSubmit(e) {
var _this = this;
console.log("submit...");
var gw = form2json('#newGatewayForm');
console.log("gw", gw);
if (!gw.name || !gw.realm) {
this.setState({errmsg: "Mandatory fields left blank"});
return;
}
xFetchJSON("/api/gateways", {
method:"POST",
body: JSON.stringify(gw)
}).then((obj) => {
gw.id = obj.id;
_this.props.handleNewGatewayAdded(gw);
}).catch((msg) => {
console.error("gateway", msg);
_this.setState({errmsg: '' + msg + ''});
});
}
render() {
console.log(this.props);
const props = Object.assign({}, this.props);
const gateways = props.gateways;
const sip_profiles = props.sip_profiles;
delete props.gateways;
delete props.sip_profiles;
delete props.handleNewGatewayAdded;
const gateways_options = gateways.map(gw => {
return
});
return
;
}
}
网上找了好久也没找到原因
问一下怎么是什么原因?怎么解决?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
isMounted已经弃用了、使用componentDidMount