Hello all, in react-template-helper, is there a way to pass an argument into the component?
something like:
{{> React component=view 'myVar'}}
Thanks
Hello all, in react-template-helper, is there a way to pass an argument into the component?
something like:
{{> React component=view 'myVar'}}
Thanks
Yes, just do
{{> React component=view myVar='myVar'}}
And you can access it with this.props.myVar
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;
}
})
What are you trying to achieve by passing an argument into the component?
I want to make a global helper that returns a component depending on the argument passed in
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