亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - 使用react報錯

瀏覽:71日期:2023-04-29 14:21:32

問題描述

報錯: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 callbackthis.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 <option value={gw.id} key={gw.id}>Gateway[{gw.name}]</option>});return <Modal {...props} aria-labelledby='contained-modal-title-lg'> <Modal.Header closeButton><Modal.Title id='contained-modal-title-lg'><T.span text='Create New Gateway' /></Modal.Title> </Modal.Header> <Modal.Body> <Form horizontal id='newGatewayForm'><FormGroup controlId='formName'> <Col componentClass={ControlLabel} sm={2}><T.span text='Name' className='mandatory'/></Col> <Col sm={10}><FormControl type='input' name='name' placeholder='gw1' /></Col></FormGroup><FormGroup controlId='formRealm'> <Col componentClass={ControlLabel} sm={2}><T.span text='Server' className='mandatory'/></Col> <Col sm={10}><FormControl type='input' name='realm' placeholder='example.com' /></Col></FormGroup><FormGroup controlId='formUsername'> <Col componentClass={ControlLabel} sm={2}><T.span text='Username' className='mandatory'/></Col> <Col sm={10}><FormControl type='input' name='username' placeholder='username' /></Col></FormGroup><FormGroup controlId='formPassword'> <Col componentClass={ControlLabel} sm={2}><T.span text='Password' className='mandatory'/></Col> <Col sm={10}><FormControl type='password' name='password' placeholder='a$veryComplicated-Passw0rd' /></Col></FormGroup><FormGroup controlId='formDescription'> <Col componentClass={ControlLabel} sm={2}><T.span text='Description'/></Col> <Col sm={10}><FormControl type='input' name='description' placeholder='Description ...' /></Col></FormGroup><FormGroup controlId='formSipProfile'> <Col componentClass={ControlLabel} sm={2}><T.span text='SIP Profile'/></Col> <Col sm={10}><FormControl componentClass='select' name='profile_id' value={this.state.selectedValue} onChange={this.handleChange}> <option value='2'>public</option> <option value='1'>default</option></FormControl> </Col></FormGroup><FormGroup controlId='formTemplate'> <Col componentClass={ControlLabel} sm={2}><T.span text='Template'/></Col> <Col sm={10}><FormControl componentClass='select' name='template'> <option value='default'>Default</option> {gateways_options}</FormControl> </Col></FormGroup><FormGroup controlId='formRegister'> <Col componentClass={ControlLabel} sm={2}><T.span text='Register'/></Col> <Col sm={10}><Radio name='register' value='yes' inline><T.span text='yes'/></Radio><Radio name='register' value='no' inline><T.span text='no'/></Radio> </Col></FormGroup><FormGroup> <Col smOffset={2} sm={10}><Button type='button' bsStyle='primary' onClick={this.handleSubmit}> <i className='fa fa-floppy-o' aria-hidden='true'></i>&nbsp; <T.span text='Save' /></Button>&nbsp;&nbsp;<T.span className='danger' text={this.state.errmsg}/> </Col></FormGroup> </Form> </Modal.Body> <Modal.Footer><Button onClick={this.props.onHide}> <i className='fa fa-times' aria-hidden='true'></i>&nbsp; <T.span text='Close' /></Button> </Modal.Footer></Modal>; }}

網(wǎng)上找了好久也沒找到原因問一下怎么是什么原因?怎么解決?

問題解答

回答1:

isMounted已經(jīng)棄用了、使用componentDidMount

標簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 午夜视频在线观看视频 | 久久优 | 北条麻妃99精品青青久久 | 黄色一级录像 | 精品夜夜春夜夜爽久久 | 好爽快一点视频在线观看 | 国产一区二区三区欧美精品 | 在线观看精品一区 | 99九九影院理论片在线 | 日韩免费三级 | 国产尻逼 | 91av视频在线免费观看 | 九九涩| 欧美亚洲黄色片 | 亚洲国产成人综合 | 九九99视频在线观看视频观看 | 国产午夜成人无码免费看 | 999热成人精品国产免 | 精品国产福利一区二区在线 | 国内精品一区二区三区东京 | 日本一本久道 | 国产精品人伦久久 | 欧美大片aaaa一级毛片 | 亚洲精品国产第一区二区尤物 | 狠狠色婷婷综合天天久久丁香 | 成人高清视频在线观看大全 | 亚洲精品91香蕉综合区 | 久久久99精品| 欧美俄罗斯一级毛片激情 | 一级毛片在线看在线播放 | 韩国主播19福利视频在线观看 | 看中国国产一级毛片真人视频 | 国产精品一区在线免费观看 | 国产91在线播放中文 | 一级毛片免费不卡在线 | 欧美色黄毛片 | 最新avtom永久地址免费 | 蜜桃视频一区 | 黄色大片国产 | 在线无限看免费网站 | 在线看一区二区 |