2017-07-24 20 views
0

我知道我們可以SETSTATE或動態變量傳遞JXS動態道具使用字符串字面

this.state[`id-$(id)`]this.state[someVariable]得到國家,但我們可以通過動態道具下來的孩子組成部分?

<div what_to_do_here={this.state[`id-${id}`]} />hello</div> 
+0

那麼它工作? –

+0

你想讓id由子組件提供嗎? – marzelin

回答

1

一種方法是通過使用一個物體來收集你的道具+擴散算子(ES2015)。

render() { 
    const myProps = { a: 4, f: 1 }; 
    return <Application {...myProps} />; 
    }