Passing arguments to react-template-helper's "component="


#1

Hello all, in react-template-helper, is there a way to pass an argument into the component?
something like:

{{> React component=view 'myVar'}}

Thanks


#2

Yes, just do

{{> React component=view myVar='myVar'}}

And you can access it with this.props.myVar


#3

Thank you for the reply merlinpatt

Apologies for not being clear on the question, what I am trying to achieve is passing an argument when view in component=view is evaluated. For example

{{> React component=view 'hello'}}
Template.Home.helpers({
  view: function (bar) {
    console.log(bar)  // logs 'hello'
    ...
    return someComponent;
  }
})

#4

What are you trying to achieve by passing an argument into the component?


#5

I want to make a global helper that returns a component depending on the argument passed in


#6

You can do this within React and will be much easier than trying to do it through Blaze. Check it out here http://stackoverflow.com/questions/26518629/dynamically-rendering-a-react-component