I have amazingly simple and terrible problem.
Let's say, I have a React component (called List
) wrapped by createContainer
:
class List extends Component {
render() {
return (
...
);
}
}
export default createContainer({
...
}, List);
List
has one prop from parent: activeListId
.
I use createContainer
to subscribe for subscription, but i need to pass a parameter inside that subscription. The parameter is activeListId
value.
export default createContainer({
Meteor.subscribe('ListItems', this.props.activeListId);
return {
...
}
}, List);
So I need to have an access to props of the original component inside the createContainer
code. It is so strange but I can not do this! this
context inside createContainer
is different from this
inside List
.
Who knows how to achieve that?
As its first argument, createContainer
should receive a function that takes props
as an argument. So you need to do this:
export default createContainer(props => {
Meteor.subscribe('ListItems', props.activeListId);
return {
...
}
}, List);