8
我被告知參考文獻可能會被棄用。獲取元素參考而不使用反應中的參考
我怎能實現以下,考慮到這代碼:
export default class DemoAxis extends Component {
componentDidMount() {
const el = this.refs.line;
const dimensions = .getDimensionsFromElement(el);
}
render() {
return (
<div ref="line">
</div>
);
}
我需要行格的引用,從它那裏得到的尺寸。
我知道有一個ref回調,我應該使用它嗎?
@MarcoScabbiolo https://facebook.github.io/react/docs/more-about-refs.html#the-ref-string-attribute –