javascript - reactjs (+meteor) on browser resize change style but not rerender complete childs tree -
im changing style of component root div browser resize. triggers every single child render also. im in process of doing complex map many child components including tables , fb fixed table component.
the component has basicly 3 child tables 1 of them gets new width/height main component. in there own divs.
i started react few days ago, hope can give me tips. please let me know if unclear.
resizing:
getinitialstate: function() { return { windowwidth: window.innerwidth, windowheight: window.innerheight }; }, handleresize: function(e) { this.setstate({ windowwidth: window.innerwidth, windowheight: window.innerheight }); }, componentdidmount: function() { window.addeventlistener('resize', this.handleresize); }, componentwillunmount: function() { window.removeeventlistener('resize', this.handleresize); },
style object
var style = { width: this.state.windowwidth, height: this.state.windowheight, position: "absolute" };
render()
return ( <div classname="map_quadrant" ref="map_quadrant" style={style}> ... <div classname="column"> <div classname="ui top attached segment"> <div classname="ui top attached label">current selection summary {this.props.model._name}</div> <summarytable model_name={this.props.model._name} model={this.props.model} keys={this.props.model.simpleschema()._schemakeys} /> </div> </div> <div> <mastertable width={this.state.windowwidth} height={this.state.windowheight/2} model_name={this.props.model._name} data={this.state.model_data} keys={this.props.model.simpleschema()._schemakeys} /> </div>
(its experimental code, not optimal)
Comments
Post a Comment