0
親から来たが小道具が1つ変更された小道具はどうやって送るのですか?子供に送るthis.props with one props
私はレンダリングしているページがあります。InputList
コンポーネント。そして、このコンポーネントでは、InputList
を再度レンダリングしています。だから、私は{...this.props}
を1つの小道具交換で送る。modal
。しかし、私が<InputList modal={true} {this.props}/>
を送るとき。 modal
の値は...this.props
からです。値はtrue
の代わりにfalse
となります。
確かに、すべての小道具を個別に送る可能性がありますが、小道具がたくさんあるので、私はthis.props
を使用します。または、私はconst { modal, ...others} = this.props
のようなものを使用できますが、私はconst { modal,...,...,...,...,...} = this.props
class Page extends Component{
render(){
return(
<InputList modal={false} list={...} valueA={..} valueB={..}
firstTitle={..} secondTitle={..} />
)
}
}
class InputList extends Component{
render(){
const {modal,list,valueA,valueB,firstTitle,secondTitle} = this.props;
....
return(
....
<InputList modal={true} {...this.props} />
)
}
}
ありがとうございますが、これは唯一の解決策ですか? –