facebookarchive / react-meteor

React rendering for Meteor apps
948 stars 114 forks source link

Compatibility between React and Blaze #44

Closed mitar closed 9 years ago

mitar commented 9 years ago

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}}}?

hellogerard commented 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)?

mitar commented 9 years ago

That sounds cool.

benjamn commented 9 years ago

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}}.

benjamn commented 9 years ago

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.

benjamn commented 9 years ago

I figured out a way to work around the destructive behavior of React.render! Fix coming momentarily.

benjamn commented 9 years ago

I think this is pretty neat: 2790942d5467cfb0e4364a33dedb569314f10ea3. Now React components in Blaze templates look just like any other Blaze template.

mitar commented 9 years ago

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?

benjamn commented 9 years ago

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.

mitar commented 9 years ago

And cleanup could be done, where?

sarahkevinking commented 9 years ago

@benjamn it seems that this causes some unexpected behavior (see #48) when you attempt to update the contents of a react node.