I've been learning React and how to integrate it with Meteor over the past couple weeks. One issue I've been running into, is when using FlowRouter and ReactLayout, I can't seem to figure out how to pass properties/functions from the parent/layout component to child components that ReactLayout renders. Here is an example of what I am trying to do:
// Layout component with function to pass
MainLayout = React.createComponent({
functionToPass() {
do some stuff...
},
render() {
return (
<div>
{this.props.content}
</div>
)
}
});
// Component to pass into main layout
DynamicComponent1 = React.createComponent({
render() {
return (
<div>
<h1>This component will change</h1>
<button onClick={this.props.functionToPass}>Press me!</button> // property passed from layout component
</div>
)
}
});
// FlowRouter
FlowRouter.route('/', {
action() {
ReactLayout.render(MainLayout, {
content: <DynamicComponent1 /> // Somehow I need to pass MainLayout.functionToPass() to DynamicComponent1 here
}
}
});
I should note that I know how to pass properties to components that aren't dynamically changing - render directly in MainLayout. This is not what I am trying to do, however. Many thanks!