In my case, im using few buttons and when a button is clicked, there should be a change in view. for the view i am using same panel for each button click and the change will be apply on heading of the panel( company name). To change the name I am sending parameter with Onclick method like below.
class View extends Component {
constructor(props){
super(props)
this.state ={
message: <Content name="ABC"/>
}
}
changeStateMSG(prevStep,props){
this.setState({
message:<Content name={this.props.name}/>
})
}
render() {
return (
<div className="row">
<div className="mr-sm-3">
<div style={{ width: '18rem', marginTop: '20px' }}>
<Button onClick={() => this.changeStateMSG(this.props.name="XYZ")} variant="secondary" size="lg" block >
Omobio
</Button>
<div className="mr-sm-9">
<p>{this.state.message}</p>
</div>
.... when i pass parameter like above (this.props.name="XYZ") i am getting error as "TypeError: Cannot add property name, object is not extensible". Hope some can help me
Content) in the state.