React: attach react component to already rendered DOM (which is not rendered by react on server)

Created on 13 Sep 2016  路  4Comments  路  Source: facebook/react

I'd like to keep traditional server side rendering (not react rendering with node) and attach client side code.
I believe the following statement might help to achieve that. I wonder if any work is being done.
Or any help or guide on how to mix server rendered content (via server side template such as jinja2 ) with react at the moment would be greatly appreciated.

https://facebook.github.io/react/docs/top-level-api.html states that

ReactDOM.render() does not modify the container node (only modifies the children of the container). In the future, it may be possible to insert a component to an existing DOM node without overwriting the existing children.

Most helpful comment

Technically React 16 can attach to non-React-generated markup although this is pretty fragile.

All 4 comments

There is currently no support for React component reusing non-React-generated markup. Your next best bet would be to use server rendering for static non-React parts, and mount React components on the client side inside those DOM nodes.

Technically React 16 can attach to non-React-generated markup although this is pretty fragile.

Technically React 16 _can_ attach to non-React-generated markup although this is pretty fragile.

@gaearon are you referring to Portals?

Was this page helpful?
0 / 5 - 0 ratings