Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
if (this.root.ref) {
const anchor = closest(
this.root.ref,
`.${MDCMenuSurfaceFoundation.cssClasses.ANCHOR}`
);
anchor && (this.anchorElement = anchor);
}
// this has to be run AFTER we try to get our anchor
super.componentDidMount();
}
useEffect(() => {
const el = rootEl.ref;
if (el) {
const anchor = closest(
el,
`.${MDCMenuSurfaceFoundation.cssClasses.ANCHOR}`
);
anchor && (anchorElementRef.current = anchor);
}
}, [rootEl.ref]);