Fix performance bug (#984)

This commit is contained in:
Pete Hunt 2020-03-16 19:07:47 -07:00 committed by GitHub
parent f4cc4253b8
commit e9f5175f51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 121 additions and 95 deletions

View file

@ -1,5 +1,6 @@
import React, { useLayoutEffect, useRef, useEffect } from "react";
import "./Popover.css";
import { unstable_batchedUpdates } from "react-dom";
type Props = {
top?: number;
@ -39,7 +40,7 @@ export function Popover({
if (onCloseRequest) {
const handler = (e: Event) => {
if (!popoverRef.current?.contains(e.target as Node)) {
onCloseRequest();
unstable_batchedUpdates(() => onCloseRequest());
}
};
document.addEventListener("pointerdown", handler, false);