The change of the react subcomponent state triggers the render function. How does the parent component perceive the change of the subcomponent?

the child component clicks the button to change its state to trigger the render update, but does not change the state state of the parent component, so how does the parent component sense that the child component has been re-render?

parent component code

import React from "react";
import TodoItem from "./TodoItem.js";
class TodoList extends React.Component{
    constructor(){
        super();
    }
    render(){
        return (
            <div>
                <TodoItem/>
            </div>
        )
    }
    
    
}
export default TodoList;

subcomponents

import React from "react";

class TodoItem extends React.Component{
    constructor(){
        super();
        this.state = {
            greet:"hi"
        }
        this.handlerChange = this.handlerChange.bind(this);
    }
    render(){
        return (
            <div>
                <div>{this.state.greet}</div>
                <button onClick={this.handlerChange}>state</button>
            </div>
        )
    }
    handlerChange(){
        this.setState(()=>{
            return{
                greet:"hello"
            }
        })
    }
}
export default TodoItem;
May.12,2022

the communication between the parent component and the child component uses props, and the communication between the child component and the parent component uses the callback function


if the parent component needs to listen for changes in the child component, it is recommended to move the state to the parent component


to pass a method similar to onChange to the child component. If the child component status update, call onChange , onChange define in the parent component. Don't you know that the subcomponents are updated

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-1eaa5f2-1fc5.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-1eaa5f2-1fc5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?