Hey, I have a question.
I have AdminLayout with reactive meteor data and a route:
FlowRouter.route('/test', {
action: function () {
ReactLayout.render(AdminLayout, {
content: <AdminPermissions />
});
}
});
So, in the top AdminLayout I have getMeteorData() and render:
getMeteorData() {
return {
currentUser: Meteor.user()
};
},
render() {
<section>
{this.props.content}
</section>
}
Now I need to pass this.data.currentUser
as props to its child (AdminPermissions), but I don’t know how. The suggestion in the issue seems to be wrong.
I’ve managed to do a hack. Basically, the finished structure is:
<AppComponent> (does nothing, only has the place to insert parts)
<AdminLayout> (has reactive data and passes it to children)
<AdminPermissions> (finally has the props)
Code:
- App Component (only has areas to insert parts)
AppComponent = React.createClass({
render() {
return (
<section>
{this.props.layout}
</section>
)
}
});
- AdminLayout (has reactive meteor data and sends props)
AdminLayout = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
return {
currentUser: Meteor.user(),
};
},
render() {
// HACK or NOT ?
let component = React.createElement(this.props.component, {
user: this.data.currentUser
});
return (
<section>
{component}
</section>
);
}
});
- AdminPermissions (has props from the reactive source)
AdminPermissions = React.createClass({
render() {
return (
<section>
{this.props.user.username}
</section>
);
}
});
- The route, combining 3 components
FlowRouter.route('/test', {
action: function () {
ReactLayout.render(AppComponent, {
layout: <AdminLayout component={AdminPermissions}/>
});
}
});
I do believe that top component should have the user reactive state, not the child ones.
Is this the way to pass reactive data to children? Or am I doing something wrong?