Calling meteor template from react components


#1

Hi, This is Harsha I am working on meteor from couple of days, and now working on meteor with react.

I am in a situation where I want to call meteor templates from react components and I am stuck. Anyone please help me to overcome this problem.

Thanks in advance,
Harsha Vardhan P V K.


#2

You can call/render a Blaze template using a custom React component - see this example component from the meteor-webpack-react project. Just copy the component to your project, but delete the first import line and replace export default with BlazeTemplate = to export it as a global (I assume you’re not using webpack and/or ES6 modules). Then you can simply render any Blaze template you need anywhere from React with: -

<BlazeTemplate template={Template.yourtemplatename} />

#3

Thank you for your response can you once please check this topic also…


#4

Thanks for the pointer @firegoby.

JFYI the file seems to have changed since you linked to it, so here is a permalink to the version you referenced, and here is a gist with the s/export default/BlazeTemplate =/ change you suggested, that should be able to be dropped in to any Meteor project.