我知道我们可以在动态变量上设置state或获取状态
与this.state[`id-$(id)`]
或this.state[someVariable]
类似,但我们可以将动态道具传递给子组件吗?
<div what_to_do_here={this.state[`id-${id}`]} />hello</div>
答案 0 :(得分:1)
一种方法是使用一个物体来收集你的道具+传播操作员(ES2015)。
render() {
const myProps = { a: 4, f: 1 };
return <Application {...myProps} />;
}