Я создал новый компонент, но, конечно, он реализуется во многих других компонентах на той же странице. Я хотел знать, смогу ли я получить элементы по имени класса относительно ссылки, которую я создал?
Я уже пытался получить элементы по имени класса, но я получаю элементы вне рамок того, что я пытаюсь получить.
import React, { Component } from 'react';
export default class test extends Component {
constructor(props) {
super(props);
this.state = {};
this.onchange = this.onchange.bind(this);
this.componentRef = React.createRef();
}
onchange = (event) => {
//This is where I'm not sure if I can get elements by classname in reference to the ref I've created
let elements = this.componentRef.current;
};
render() {
return <div ref={this.componentRef} />;
}
}