Search code examples
reactjsreact-reduxsetstatereact-props

How to Change Props value in React Js?


Following is code below and now I wanted to change the value of name within the same component? How do I achieve this??

render(){
return(
<div>
<p>{this.props.name}</p>
</div>
)
}

Solution

  • props should not be changed in react, they are readonly. update them in the parent component and then pass them down as the new value. the component receiving them should just be displaying them and the logic handling should occur at a higher level