DEV Community

liu550
liu550

Posted on

Cannot call a child component's function from the parent component. Error: “…is not a function”

Hi,

For my website I want to include a feature that helps users randomly click a link programatically. The event happens in the parent component called StreamingPlaza, and its has a list of children components called StreamingCard, each containing a streaming link. The attached screenshots are my code. I got the error "this.roomclicks.current[0].handleClick is not a function." I tried console.log(this.roomclicks.current[0]), and it did print out the StreamingCard child component. I looked through many relevant stackoverflow posts, and the answers suggested that this code was supposed to work. I would appreciate a lot if someone can tell me where I get it wrong. Thanks!

Alt Text

Alt Text

Top comments (0)