Reputation: 439
Is there any way how send any props that with come from parent, but with one props changed?
I have some page, where i am rendering InputList
component. And in this component, i am rendering InputList
again . So i am sending down {...this.props}
with one props change - modal
. But when i send down <InputList modal={true} {this.props}/>
. The modal
value is taking from ...this.props
. so the value is false
instead of true
, any tips?
Sure, there is a possibility of sending all props individually but i have a lot of props, so i want use this.props
.. Or i can use something like const { modal, ...others} = this.props
, but there are more props, that with i am using so i have 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} />
)
}
}
Upvotes: 0
Views: 68
Reputation: 1389
Will this work for you?
class InputList extends Component {
render(){
const passProps = Object.assign({}, this.props, {modal: true})
return(
....
<InputList {...passProps} />
)
}
Upvotes: 1