Dropdown: check ref exists

Fixes urbit/landscape#805
This commit is contained in:
Liam Fitzgerald 2021-04-22 15:16:02 +10:00
parent 1a01e58b7b
commit 24259dab87
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -47,6 +47,9 @@ export function Dropdown(props: DropdownProps): ReactElement {
const [coords, setCoords] = useState({});
const updatePos = useCallback(() => {
if(!anchorRef.current) {
return;
}
const newCoords = getRelativePosition(anchorRef.current, props.alignX, props.alignY, offsetX, offsetY);
if(newCoords) {
setCoords(newCoords);