Yes, you can do all this as you wish. Here, for example, in the parent PageExample you send props data that you received from the API and recorded in the dataAPI state in the MyModal component.
Suppose there is a function in PageExample in which we receive data and put it into the state:
loadDatafromAPI() { // тут какой-то код получения данных (к примеру) let data = ... // и запись этих данных в state this.setState({ dataAPI: data }); }
And then inside PageExample you create your MyModal component to which you transfer this data via props :
<MyModal data={this.state.dataAPI} />
and already inside your MyModal , in the constructor, you can assign them to the local state:
constructor(props) { super(props); this.state = { dataAPI: props.data } }
As for componentDidMount , it is possible in it, for example, here: componentDidMount () recommends downloading data from a remote endpoint (for network requests) inside it. However, calling setState({..}) in this method will cause additional rendering, but this will happen before the browser refreshes the screen. I would write in the designer.