【发布时间】:2017-07-26 11:48:06
【问题描述】:
我不知道如何解决此警告。这是发送警告的组件:
警告:ReporteBoxMapRaster 正在将隐藏类型的不受控输入更改为受控。输入元素不应从不受控切换到受控(反之亦然)。在组件的生命周期内决定使用受控输入元素还是不受控输入元素。更多信息:htt fb sitereact-controlled-components
var ReporteBoxMapRaster = React.createClass({
print: function(){
$(ReactDOM.findDOMNode(this.refs.print_form)).submit();
},
render: function() {
if( this.props.extent ){
var legend = null;
switch( this.props.legend ){
case 'solid':
legend = <ReporteLegendSolid values={ this.props.values } />;
break;
case 'gradient':
legend = <ReporteLegendGradient values={ this.props.values } />;
break;
}
if( this.props.extra )
var extra = this.props.extra;
else
var extra = '';
var extent = this.props.extent;
var url = 'http://XXX.XXX.XXX/cgi-bin/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&';
url += 'LAYERS='+ this.props.layer +'&';
url += 'map=/opt/mapfile/reporte/'+ this.props.mapfile +'.map&';
url += 'TILED=false&WIDTH=780&HEIGHT=440&STYLES=&';
url += 'CRS=EPSG:' + this.props.epsg + '&';
url += 'BBOX=' + extent[0] + ',' + extent[1] + ',' + extent[2] + ',' + extent[3];
url += extra;
return (
<div className="uk-width-large-2-2 reporte-box reporte-box-target" >
<div className="md-card md-card-hover md-card-overlay " >
<div className="md-card-toolbar full2">
<div className="md-card-toolbar-actions">
<Full_screem_inter />
<span onClick={this.print} ><i className="md-icon material-icons md-card-overlay-toggler" >print</i></span>
</div>
<h3 className="md-card-toolbar-heading-text">{ this.props.title }</h3>
</div>
<div className="md-card-content uk-text-center" >
<div className="" >
<div className="map-container" >
<img className="mapimage" ref="mapImageBG" src={ this.props.bgimage } />
<img className="mapimage" ref="mapimageWMS" src={ url } />
</div>
</div>
<div className="reporte-onlyonfull">
Leyenda
</div>
<div>
{ legend }
</div>
<div className="reporte-onlyonfull">
<div>
</div>
</div>
</div>
<div className="md-card-footer" ></div>
</div>
<form ref="print_form" action={ Routing.generate("exportmaptopdf") } method="post" target="_blank" className="hidden" >
<input name="legend" type="hidden" value={JSON.stringify( this.props.values )} />
<input name="legendType" type="hidden" value={this.props.legend} />
<input name="title" type="hidden" value={this.props.title} />
<input name="bgsrc" type="hidden" value={this.props.bgimage} />
<input name="src" type="hidden" value={ encodeURI( url ) } />
</form>
</div>
);
}
else
return (<div></div>);
}
});
module.exports = ReporteBoxMapRaster;
【问题讨论】:
-
将输入中的值更改为 defaultValue。 docs
-
嗯,是的,现在我没有该组件的警告,但另一个有同样的问题,还有更多。将 value 更改为 defaultValue 会有副作用吗?
-
显示另一个错误。
标签: reactjs