我在 reactjs 中有以下代码:如何使用 ID 访问任何组件(如 jquery)或有其他解决方案?
进度条.jsx
class Progressbar extends Component {
constructor() {
super();
this.state = { percentage: 0 };
}
progress(percentage) {
this.setState({ percentage:percentage });
}
render() {
// using this.state.percentage for the width css property
........
........
}
};
文件上传器.jsx
class FileUploader extends Component {
onUploadProgress() {
// I want to call Progress1.progress( percentage_value )
}
render() {
........
<Progressbar id="Progress1" />
........
........
}
};