Fix some bugs

This commit is contained in:
2023-07-21 15:42:11 +09:00
parent 3107f4de80
commit 3c8ac297b2
3 changed files with 6 additions and 9 deletions

View File

@ -13,10 +13,7 @@ export const ExcalidrawMain = () => {
const [toggleState, setToggleState] = useState<boolean>(false);
const onClose = useCallback(
() => setToggleState(!toggleState),
[toggleState]
);
const onClose = useCallback(() => setToggleState(false), []);
return (
<ExcalidrawContainer

View File

@ -3,7 +3,7 @@ import type {
ExcalidrawProps,
ExcalidrawImperativeAPI,
} from '@excalidraw/excalidraw/types/types';
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
import { FC, useEffect, useMemo, useState } from 'react';
import styled from 'styled-components';
export type WindowRect = {
@ -46,17 +46,17 @@ export const ExcalidrawContainer: FC<ExcalidrawContainerProps> = (props) => {
height: window.innerHeight,
});
const onResize = useCallback(() => {
const onResize = () => {
setWindowRect({
width: window.innerWidth,
height: window.innerHeight,
});
}, []);
};
useEffect(() => {
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, [onResize]);
}, []);
return (
<ExcalidrawBox $scale={scale} $windowRect={windowRect}>

View File

@ -21,7 +21,7 @@ const RightTopUI: FC<RightTopUIProps> = (props) => {
const sidebarToggle = useCallback(
(variant: SidebarVariant) => {
if (excalidrawAPI && !props.toggleState) {
props.setToggleState(props.toggleState);
props.setToggleState(true);
props.setSidebarVariant(variant);
excalidrawAPI.toggleMenu('customSidebar');
}