成人视屏在线观看-国产99精品-国产精品1区2区-欧美一级在线观看-国产一区二区日韩-色九九九

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

javascript - 使用react報(bào)錯(cuò)

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

問(wèn)題描述

報(bào)錯(cuò):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)上找了好久也沒(méi)找到原因問(wèn)一下怎么是什么原因?怎么解決?

問(wèn)題解答

回答1:

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

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 美女视频黄a视频免费全过程 | 欧美视频在线一区二区三区 | 一级在线免费视频 | 全国男人的天堂网 | 欧美性群另类交 | 毛片网站视频 | 免费观看性欧美大片无片 | 久久精品国产欧美 | 国产男女爽爽爽爽爽免费视频 | 日本理论在线播放 | 久久久久欧美精品 | 欧美日韩精品高清一区二区 | 99精品久久久久久久 | 日本a级片免费观看 | 亚洲日本一区二区三区在线 | 成年黄色网址 | 亚洲午夜久久 | 色播亚洲精品网站 亚洲第一 | 亚洲国产成人久久综合一区77 | 免费公开视频人人人人人人人 | 最近中文字幕精彩视频 | 在线观看亚洲国产 | 26uuu影院亚洲欧美综合 | 久久精品香蕉视频 | avtt亚洲一区中文字幕 | 日本三级毛片 | 午夜看毛片 | 久久精品一区二区国产 | 国产一及片| 亚洲精品综合欧美一区二区三区 | 视频精品一区二区 | 亚洲精品欧美精品国产精品 | 一色屋色费精品视频在线看 | 免费国产不卡午夜福在线观看 | 欧美一级毛片免费播放器 | 在线免费精品视频 | 美女的让男人桶到爽软件 | 久久国产精品二区99 | 国产精品视频久久久久 | 精品视频一区二区三区四区 | 99在线精品免费视频 |