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

您的位置:首頁技術文章
文章詳情頁

javascript - 使用react報錯

瀏覽:63日期: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>; }}

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

問題解答

回答1:

isMounted已經棄用了、使用componentDidMount

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 一区二区三区网站 | 国产性较精品视频免费 | 亚洲精品影院 | 奶茶视频污 | 99久久99久久精品免费看蜜桃 | 色一情一乱一乱91av | 国产一级特黄aa毛片 | 国产精品欧美亚洲韩国日本99 | 国产九色在线播放 | 欧美亚洲视频 | 国产亚洲自拍一区 | 成人国产在线视频 | 国产白领丝袜办公室在线视频 | 日本在线黄色 | 91成人国产网站在线观看 | 久热re这里只有精品视频 | 午夜激情在线视频 | 国产在线精彩视频 | 亚洲自拍第二页 | 99re最新 | 欧洲成人在线视频 | 国产精品爱久久久久久久9999 | 国产成人精选视频69堂 | 久久青草精品免费资源站 | 国产好痛疼轻点好爽的视频 | 日韩欧美精品中文字幕 | 麻豆精品视频 在线视频 | 色婷婷综合久久久 | 大尺度做爰视频吃奶www | 婷婷丁香五月中文字幕 | 最新露脸国产精品视频 | 成 人 免费 黄 色 视频 | 999热成人精品国产免 | 欧美日韩亚洲精品国产色 | 日本成日本片人免费 | 午夜在线观看cao | 最新毛片网 | 欧美一区二区久久精品 | 99久久er热在这里都是精品66 | 视频一区二区不卡 | 黄色电影毛片 |