Access function from another Component using ref (TypeScript)

about 2 years ago - Direct link

I'm not sure if this is possible on functional components. But back when I was still using Class Based Components, I was able to access functions inside another class, just by using refs.

class ParentComponent extends Component {

onCLick() = {
this.childRef.current.childFunction()
}

render() {
return (

)
}
}

class ChildComponent extends Component {

childFunction() {
//... do something
}
//render.....
}

How can I do this using functional components and w/ TypeScript?


Go to article →