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. Below is my code:
Streaming Plaza
class StreamingPlaza extends Component {
  state = {
    ......
    }
    roomclicks = React.createRef([]);
    componentDidMount() {
      this.roomclicks.current[0].handleClick();
   }
     renderRoom = (room) => {
        return <StreamingCard info={room} ref={(ref) => {this.roomclicks.current[0] = ref}}></StreamingCard>;
     render() {
       const rooms = this.props.rooms;
       return (
        { rooms && rooms.map (room => {
          return this.renderRoom(room);  
        })
      }
    );
}
}
Streaming Card
class StreamingCard extends Component {
  constructor(props){
    super(props);
    this.state = {
     ......
    }
  handleClick = () => {
    console.log("called");
    document.getElementById("link").click();
  }
  render() {
    return (
       ✔️ Streaming Link: <a id="link" href=......></a>
    );
  }
 }
I got the error "this.roomclicks.current[0].handleClick is not a function." 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!
