Fix some bugs
This commit is contained in:
@ -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
|
||||
|
@ -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}>
|
||||
|
@ -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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user