javascript - Run a PhosphorJS DockerPanel with Widgets INSIDE a React component -
i have react app, , in 1 of components render phosphor desktop (http://phosphorjs.github.io).
web sources suggest other way around, running react component inside phosphor widget, need wrap phosphor desktop widgets inside react component instead. not sure how go it.
this first attempt:
import react, { component } 'react'; import './app.css'; import { dockpanel } 'phosphor-dockpanel'; import { message } 'phosphor-messaging'; import { tabpanel } 'phosphor-tabs'; import { resizemessage, widget } 'phosphor-widget'; class mywidget extends widget { static createnode() { console.log('widget:createnode'); var node = document.createelement('div'); var app = document.createelement('div'); app.classname = 'todoapp'; node.appendchild(app); return node; } constructor(model) { super(); this.addclass('todowidget'); this._model = model; console.log('widget:constructor'); } model() { console.log('widget:getmodel'); return this._model; } onafterattach(msg) { console.log('onafterattach'); //this._model.subscribe(() => this.update()); this.update(); } onupdaterequest(msg) { console.log('widget:onupdaterequest'); var data = { model: this._model }; var host = this.node.firstchild; //react.render(react.createelement(app.todoapp, data), host); } } class reactdockpanel extends component { constructor(props) { super(props); } componentwillmount() { this.panel = new dockpanel(); this.panel.id = this.props.id; this.widget = new mywidget(); this.panel.insertleft(this.widget); } componentdidmount() { this.panel.attach(this.node); } render() { return ( <div ref={el=>this.node=el}> </div> ); } } class app extends component { render() { return ( <reactdockpanel id='main'> </reactdockpanel> ); } } export default app;
i'm not sure how replace react.render(react.createelement(app.todoapp, data), host); phosphor docs reference not learning i'm going example code.
ideally i'd able render this:
<reactdockpanel id='mydesktop'> <somewidget insert='left' /> <someotherwidget insert='right' /> </reactdockpanel>
not sure can done.
Comments
Post a Comment