Push this.props’ value to the state of child component

  javascript, reactjs, typescript

I need to push values which are coming from props to the state.

I have a value, this.props.faculty = 19 which comes to me from parent.
Now, each time I get a value from parent, I want to push it to my state in child. So, in the end in my child I would have something like this:

this.state.faculties = [19, 20, 13 etc]

How can I do that?
I use React.js with TypeScript.

Source: Ask Javascript Questions

LEAVE A COMMENT