의 응답이
render() {
const containerStyle = {
left : `-${Math.min(this.state.left, this.state.x) - 35}px`,
};
return (!!this.state.visible &&
<div
className={styles.container}
style={containerStyle}
ref={(element) => { this.container = element; }}
>
: 여기
componentDidMount() {
this.setState({
left: Math.round(this.container.getBoundingClientRect().width),
x: Math.round(this.container.getBoundingClientRect().x)
});
}
그리고
는 렌더링 함수의 시작입니다. 인라인 심판을 사용하면 첫 번째 렌더 패스가 ref가 null이됩니다. 콜백을 전달할 때 요소가로드 된 후에 만 호출됩니다.
applyRef(ref) {
this.container = ref;
}
...
<div
className={styles.container}
style={containerStyle}
ref={this.applyRef}
>
그래, 그 작품 :). 감사 인사 – user2391356