reactjs - Using a jquery modal with React view switching -
i'm bit of novice when comes react, can help.
i've been able create generic view switching component using react.
var viewswitchercontainer = react.createclass({ getinitialstate: function() { return { activeviewname : this.props.views[0].name }; }, selectview: function(name) { this.state.activeviewname = name; this.forceupdate(); }, render: function () { return <div> <viewswitcher views={this.props.views} onviewselection={this.selectview}/> <viewswitchercontent views={this.props.views} activeviewname={this.state.activeviewname}/> </div>; } });
here jsfiddle demonstration... http://jsfiddle.net/paheal/j8ubc/
however when try load switching component in modal component an
'uncaught error: invariant violation: findcomponentroot(..., .r[3iziq].[1].[0].[1]): unable find element. means dom unexpectedly mutated (e.g. browser).' error react.
var modalview = react.createclass({ getinitialstate: function () { this.viewdefinitions = [ {displayname:'view a', name:'viewa', view:viewa}, {displayname:'view b', name:'viewb', view:viewb} ]; return {}; }, componentdidmount: function () { $("#" + this.props.modalid ).dialog({ autoopen: false, height: 400, width: 400, modal: true, draggable: false, resizable: false }); }, render: function () { return <div id={this.props.modalid} title={this.props.modalid}> <viewswitchercontainer views={this.viewdefinitions}/> </div>; } });
here jsfiddle demonstration... http://jsfiddle.net/paheal/j8ubc/7/
what missing? problem in modal component or in view switching components?
i worked out wrong. seems dialog functionality in jqueryui adds dom, dynamically creating div dialog , title bar.
depending on timing of things, can cause issues when react doing reconciliation.
to resolve implemented reactified version of modal dialog.
Comments
Post a Comment