From 4a0800a5df9d73da5d67dba6683b5830ef7c4d9b Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Wed, 8 Sep 2021 11:27:05 +0100 Subject: [PATCH] cleanup --- .../core/src/components/renderer/renderer.tsx | 28 +------------------ packages/dev/src/app.tsx | 2 -- .../tldraw/src/components/tldraw/tldraw.tsx | 15 +--------- .../components/tools-panel/tools-panel.tsx | 4 --- packages/tldraw/src/state/tlstate.spec.ts | 4 +-- 5 files changed, 4 insertions(+), 49 deletions(-) diff --git a/packages/core/src/components/renderer/renderer.tsx b/packages/core/src/components/renderer/renderer.tsx index 0b7976543..c22acaf55 100644 --- a/packages/core/src/components/renderer/renderer.tsx +++ b/packages/core/src/components/renderer/renderer.tsx @@ -14,11 +14,6 @@ import { useTLTheme, TLContext, TLContextType } from '../../hooks' export interface RendererProps> extends Partial { - /** - * An id representing the current document. Changing the id will - * update the context and trigger a re-render. - */ - id?: string /** * An object containing instances of your shape classes. */ @@ -57,8 +52,6 @@ export interface RendererProps void } /** @@ -70,7 +63,6 @@ export interface RendererProps>({ - id, shapeUtils, page, pageState, @@ -90,31 +82,13 @@ export function Renderer>({ rPageState.current = pageState }, [pageState]) - const rId = React.useRef(id) - - const [context, setContext] = React.useState(() => ({ - id, + const [context] = React.useState(() => ({ callbacks: rest, shapeUtils, rScreenBounds, rPageState, })) - React.useEffect(() => { - if (id !== rId.current) { - rest.onTest?.() - setContext({ - id, - callbacks: rest, - shapeUtils, - rScreenBounds, - rPageState, - }) - - rId.current = id - } - }, [id]) - return ( - + ) } function InnerTldraw({ - id, currentPageId, document, }: { - id?: string currentPageId?: string document?: TLDrawDocument }) { @@ -150,16 +143,10 @@ function InnerTldraw({ tlstate.changePage(currentPageId) }, [currentPageId, tlstate]) - React.useEffect(() => { - 'Id Changed!' - console.log(id, tlstate.id) - }, [id]) - return ( { const isDebugMode = useSelector(isDebugModeSelector) - console.log(activeTool) - const selectSelectTool = React.useCallback(() => { - console.log(tlstate.id) tlstate.selectTool('select') }, [tlstate]) const selectDrawTool = React.useCallback(() => { - console.log(tlstate.id) tlstate.selectTool(TLDrawShapeType.Draw) }, [tlstate]) diff --git a/packages/tldraw/src/state/tlstate.spec.ts b/packages/tldraw/src/state/tlstate.spec.ts index d87ce7874..8fc73a88a 100644 --- a/packages/tldraw/src/state/tlstate.spec.ts +++ b/packages/tldraw/src/state/tlstate.spec.ts @@ -447,9 +447,9 @@ describe('TLDrawState', () => { }) describe('when the document prop changes', () => { - it.todo('updates the document if the new id is the same as the old one') - it.todo('replaces the document if the ids are different') + + it.todo('updates the document if the new id is the same as the old one') }) /* We want to be able to use the `document` property to update the