mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Prefer arrow functions and callbacks (#1210)
This commit is contained in:
parent
33fe223b5d
commit
c427aa3cce
64 changed files with 784 additions and 847 deletions
|
@ -4,13 +4,13 @@ import React, { useEffect, useState } from "react";
|
|||
import { createPortal } from "react-dom";
|
||||
import { KEYS } from "../keys";
|
||||
|
||||
export function Modal(props: {
|
||||
export const Modal = (props: {
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
maxWidth?: number;
|
||||
onCloseRequest(): void;
|
||||
labelledBy: string;
|
||||
}) {
|
||||
}) => {
|
||||
const modalRoot = useBodyRoot();
|
||||
|
||||
const handleKeydown = (event: React.KeyboardEvent) => {
|
||||
|
@ -44,14 +44,14 @@ export function Modal(props: {
|
|||
</div>,
|
||||
modalRoot,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function useBodyRoot() {
|
||||
function createDiv() {
|
||||
const useBodyRoot = () => {
|
||||
const createDiv = () => {
|
||||
const div = document.createElement("div");
|
||||
document.body.appendChild(div);
|
||||
return div;
|
||||
}
|
||||
};
|
||||
const [div] = useState(createDiv);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
@ -59,4 +59,4 @@ function useBodyRoot() {
|
|||
};
|
||||
}, [div]);
|
||||
return div;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue