How react child components call methods in parent components

File A

wrote some methods

class Parents extends Component{
    scrollWidth(){
        let dataWidth = this.state.columns;
        let result = 0;
        for(let i=0;i<dataWidth.length;iPP){
            result+=dataWidth[i].width
        }
        return result
    }
    
    
    change() {
        console.log(xxxx)
    }
    
    one(){
        console.log(bbbbb)
    }
}

File B
how do you want to call the methods in the file, there is no render, in file A, just a lot of methods are saved.

class Son extends Component{
    scrollWidth  changeone

    render(){
        return(
            <div ></div>
        )
    }
}
Mar.11,2021

1. Look at your current code An and B do not have any relationship, if B is a component of A, you can pass in
2 through props. If you just want to use the method of An as a public method, you can write a public js, that does not need to inherit component, to import, directly in b and then can call the method of b. But the this called at this time does not point to an instance of component B, so it is called with
change.call (this) such

.
Menu