Reputation: 319
I know we can setState or get state on dynamic variables
like this.state[`id-$(id)`]
or this.state[someVariable]
but can we pass dynamic props down to children component?
<div what_to_do_here={this.state[`id-${id}`]} />hello</div>
Upvotes: 0
Views: 161
Reputation: 1004
one way to do it is by using an object to gather your props + the spread operator (ES2015).
render() {
const myProps = { a: 4, f: 1 };
return <Application {...myProps} />;
}
Upvotes: 1