Closed mitar closed 9 years ago
Have you checked out https://github.com/avital/react-in-blaze? And the example app using it (https://github.com/meteor/rectangles)?
That sounds cool.
What would be ideal, in my mind, is if a named Blaze Template
were automatically created for every React component class, so that you could just refer to it from Blaze like so: {{> Player name=model.name score=model.score}}
.
The annoying thing about React is that you always have to render into a fixed root container, and calling React.render(<Component />, container)
blows away all the other contents of container
.
I'm going to submit a pull request that shows my proposed solution, but I could use some feedback on simplifying the container issue.
I figured out a way to work around the destructive behavior of React.render
! Fix coming momentarily.
I think this is pretty neat: 2790942d5467cfb0e4364a33dedb569314f10ea3. Now React components in Blaze templates look just like any other Blaze template.
Is it possible also to render part of the Blaze then inside a React? So that I can have Blaze hosting React, then which hosts some other part in Blaze again?
I'm not sure exactly what would be involved, but I think you'd have to invoke Blaze.render(Template.someBlazeTemplate, parentNode)
somewhere from React code, maybe in a React wrapper component of some sort.
And cleanup could be done, where?
@benjamn it seems that this causes some unexpected behavior (see #48) when you attempt to update the contents of a react node.
Is it possible that only one Blaze template internals would be React, but that the rest of it would be Blaze? So that it is possible to use existing templates and components, and then include some React at some parts? Maybe through
{{{react}}}
?