refactor: export CanvasContextProvider to follow established context pattern

As noted [in the review](
https://github.com/drawdb-io/drawdb/pull/148#discussion_r1681584836
), I disagree with this pattern. However, I will follow it to get
these features added.
This commit is contained in:
Felix Zedén Yverås
2024-07-17 21:45:51 +02:00
parent 471d2ebdf0
commit 5a56c3b354
6 changed files with 188 additions and 171 deletions

View File

@@ -1,4 +1,4 @@
import { useContext, useRef, useState } from "react";
import { useRef, useState } from "react";
import { Button, Popover, Input } from "@douyinfe/semi-ui";
import { IconEdit, IconDeleteStroked } from "@douyinfe/semi-icons";
import {
@@ -9,6 +9,7 @@ import {
State,
} from "../../data/constants";
import {
useCanvas,
useLayout,
useSettings,
useUndoRedo,
@@ -19,7 +20,6 @@ import {
import ColorPalette from "../ColorPicker";
import { useTranslation } from "react-i18next";
import { useHover } from "usehooks-ts";
import { CanvasContext } from "../../context/CanvasContext";
export default function Area({
data,
@@ -33,7 +33,7 @@ export default function Area({
pointer: {
spaces: { diagram: pointer },
},
} = useContext(CanvasContext);
} = useCanvas();
const { layout } = useLayout();
const { settings } = useSettings();
const { setSaveState } = useSaveState();