The child component constantly passes values to the parent component, how does react implement

problem description

implement an upgraded game. After the first inning ends, the component tells the parent component to upgrade + 1, and after the second inning ends, notify the parent component to upgrade + 1

.

the environmental background of the problems and what methods you have tried

the following is how I refer to Ali"s implementation. In componentdidmount, a child component can indeed pass a value to the parent component, but after the end of the first inning, it can be the second inning, but not the third inning. If I put the function in update, the component will be refreshed one by one. Finally, ask how to solve
Link description -sharp-sharp-sharp
/ / Please paste the code text below (do not replace the code with pictures)

//
 setLevel(level){
        console.log("setLvel",level)
        this.setState({
            level
        })
        console.log("new setLvel",level)
    }
    
  render(){
        console.log("level parent ",this.state.level)

        if(this.state.level===1){
          var  _urls = urls.slice(0,4);
            randomUrls =   this.spreadImg(_urls)
        }
        
        if(this.state.level===2){
              _urls = urls.slice(0,6);
              randomUrls =   this.spreadImg(_urls);
        }
        if(this.state.level===3){
            _urls = urls.slice(0,8);
            randomUrls =   this.spreadImg(_urls);
      }

        var bgStyle = {
            backgroundImage: `url(${bg})`,
            width:"100%",
            height:"100vh",
            backgroundSize:"contain"
        };
        return (
            <div style={bgStyle}>
                <section className="stage">
                    <section>
                        <ImgFigureSection 
                        setLevel = { level => this.setLevel(level) } 
                        level={this.state.level} 
                        randomUrls = {randomUrls} />
                    </section>
                </section>
            </div>
        )
    } 
    
    componentDidMount(){
        console.log("didmount",this.state)
        if(this.state.level===1){
            setTimeout(()=>{
                this.props.setLevel(2)
            },10000)
        }else if(this.state===2){
            setTimeout(()=>{
                this.props.setLevel(3)
            },10000)
        }
    }    
    

what result do you expect? What is the error message actually seen?

among the child components, I don"t want to use setTimeout,. I want level+1, so tell the parent component to update

.
Apr.07,2021

you can call this.props.setLevel (); in a subcomponent at any time

// 
    endGane = () => {
        // 
       this.props.setLevel()
    }
    componentDidMount(){
    }   
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eafe48-48064.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eafe48-48064.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?