In react, how the parent component invokes the method of the child component, or is it possible to set the state of the child component (without redux)

if you want to ask everyone, in react, the parent component has a way to call the method of the child component, or set the state of the child component. Thank you!

Feb.28,2021

of course = We need to use props to pass-the root of redux is that there are too many state controls and it is not easy to manage, so we use redux. And in general, redux is not recommended. Can use the state of react itself to do, try to control itself. That is, if you are stubborn in a project, you can manage complex states without redux-- please take a look at the three principles of redux--
generally control the status of word components

.

read this article at noon, and recommends it to you

.
class Parent extends React.Component {
    render() {
        return(
            <div>
                <Child ref={r => this.child = r}/>
            </div>
        );
    }
    
    myFunction() {
        this.child.childFunction();
    }
}

class Child extends React.Component {
    render() {
        //....
    }
    
    childFunction() {
    
    }
}

Note that stateless does not have refs .

Menu