2016-11-27 47 views
1

我想渲染react-app服务器上的完整生命周期和更新支持。如何渲染服务器上的React到回调函数?

https://github.com/Yomguithereal/react-blessed,但不是终端,回调函数。

例,伪代码:

render(<MyComponent />, (tree)=>{ 
    console.log(tree); // new react component-tree 
}) 

又如,https://github.com/iamdustan/react-hardware

https://github.com/facebook/react/blob/077d660a2727e3d3d6629d3a62693f8509100139/src/renderers/testing/ReactTestRenderer.js#L138

+0

大多数反应组件都是它们自己的功能,所以我不确定你希望实现什么。 你的“新反应组件树”会不同于“未渲染”的反应组件? 你期望'tree'有什么格式?如果你能够详细阐述和描述你的用例(你可以编辑你的原始问题),这将有所帮助。 –

+0

@MichałCzapliński,树可以,例如,DOM或jsonable-DOM,它并不重要,需要更新回调调用。 – arvitaly

+0

同样,不清楚你要求什么......请花一些时间来更清楚地说出你的问题并详细说明你的用例。有一些流行的服务器端渲染框架,看看那些: https://github.com/zeit/next.js https://github.com/redfin/react-server 但是,如果我正确理解你,你需要像JSDOM(https://github.com/tmpvar/jsdom)一样模拟DOM,然后像酶中的'mount()'一样渲染整个组件(https: //github.com/airbnb/enzyme) –

回答

相关问题