Steve Ruiz 4 лет назад
Родитель
Сommit
4a0800a5df

+ 1
- 27
packages/core/src/components/renderer/renderer.tsx Просмотреть файл

@@ -14,11 +14,6 @@ import { useTLTheme, TLContext, TLContextType } from '../../hooks'
14 14
 
15 15
 export interface RendererProps<T extends TLShape, M extends Record<string, unknown>>
16 16
   extends Partial<TLCallbacks> {
17
-  /**
18
-   * An id representing the current document. Changing the id will
19
-   * update the context and trigger a re-render.
20
-   */
21
-  id?: string
22 17
   /**
23 18
    * An object containing instances of your shape classes.
24 19
    */
@@ -57,8 +52,6 @@ export interface RendererProps<T extends TLShape, M extends Record<string, unkno
57 52
    * An object of custom options that should be passed to rendered shapes.
58 53
    */
59 54
   meta?: M
60
-  // Temp
61
-  onTest?: () => void
62 55
 }
63 56
 
64 57
 /**
@@ -70,7 +63,6 @@ export interface RendererProps<T extends TLShape, M extends Record<string, unkno
70 63
  * @returns
71 64
  */
72 65
 export function Renderer<T extends TLShape, M extends Record<string, unknown>>({
73
-  id,
74 66
   shapeUtils,
75 67
   page,
76 68
   pageState,
@@ -90,31 +82,13 @@ export function Renderer<T extends TLShape, M extends Record<string, unknown>>({
90 82
     rPageState.current = pageState
91 83
   }, [pageState])
92 84
 
93
-  const rId = React.useRef(id)
94
-
95
-  const [context, setContext] = React.useState<TLContextType>(() => ({
96
-    id,
85
+  const [context] = React.useState<TLContextType>(() => ({
97 86
     callbacks: rest,
98 87
     shapeUtils,
99 88
     rScreenBounds,
100 89
     rPageState,
101 90
   }))
102 91
 
103
-  React.useEffect(() => {
104
-    if (id !== rId.current) {
105
-      rest.onTest?.()
106
-      setContext({
107
-        id,
108
-        callbacks: rest,
109
-        shapeUtils,
110
-        rScreenBounds,
111
-        rPageState,
112
-      })
113
-
114
-      rId.current = id
115
-    }
116
-  }, [id])
117
-
118 92
   return (
119 93
     <TLContext.Provider value={context}>
120 94
       <Canvas

+ 0
- 2
packages/dev/src/app.tsx Просмотреть файл

@@ -1,6 +1,4 @@
1 1
 import * as React from 'react'
2
-import Controlled from './controlled'
3
-import Basic from './basic'
4 2
 import NewId from './newId'
5 3
 
6 4
 export default function App(): JSX.Element {

+ 1
- 14
packages/tldraw/src/components/tldraw/tldraw.tsx Просмотреть файл

@@ -69,23 +69,16 @@ export function TLDraw({ id, document, currentPageId, onMount, onChange }: TLDra
69 69
   return (
70 70
     <TLDrawContext.Provider value={context}>
71 71
       <IdProvider>
72
-        <InnerTldraw
73
-          key={sId || 'tldraw'}
74
-          id={sId}
75
-          currentPageId={currentPageId}
76
-          document={document}
77
-        />
72
+        <InnerTldraw key={sId || 'tldraw'} currentPageId={currentPageId} document={document} />
78 73
       </IdProvider>
79 74
     </TLDrawContext.Provider>
80 75
   )
81 76
 }
82 77
 
83 78
 function InnerTldraw({
84
-  id,
85 79
   currentPageId,
86 80
   document,
87 81
 }: {
88
-  id?: string
89 82
   currentPageId?: string
90 83
   document?: TLDrawDocument
91 84
 }) {
@@ -150,16 +143,10 @@ function InnerTldraw({
150 143
     tlstate.changePage(currentPageId)
151 144
   }, [currentPageId, tlstate])
152 145
 
153
-  React.useEffect(() => {
154
-    'Id Changed!'
155
-    console.log(id, tlstate.id)
156
-  }, [id])
157
-
158 146
   return (
159 147
     <Layout>
160 148
       <ContextMenu>
161 149
         <Renderer
162
-          id={id}
163 150
           page={page}
164 151
           pageState={pageState}
165 152
           shapeUtils={tldrawShapeUtils}

+ 0
- 4
packages/tldraw/src/components/tools-panel/tools-panel.tsx Просмотреть файл

@@ -32,15 +32,11 @@ export const ToolsPanel = React.memo((): JSX.Element => {
32 32
 
33 33
   const isDebugMode = useSelector(isDebugModeSelector)
34 34
 
35
-  console.log(activeTool)
36
-
37 35
   const selectSelectTool = React.useCallback(() => {
38
-    console.log(tlstate.id)
39 36
     tlstate.selectTool('select')
40 37
   }, [tlstate])
41 38
 
42 39
   const selectDrawTool = React.useCallback(() => {
43
-    console.log(tlstate.id)
44 40
     tlstate.selectTool(TLDrawShapeType.Draw)
45 41
   }, [tlstate])
46 42
 

+ 2
- 2
packages/tldraw/src/state/tlstate.spec.ts Просмотреть файл

@@ -447,9 +447,9 @@ describe('TLDrawState', () => {
447 447
   })
448 448
 
449 449
   describe('when the document prop changes', () => {
450
-    it.todo('updates the document if the new id is the same as the old one')
451
-
452 450
     it.todo('replaces the document if the ids are different')
451
+
452
+    it.todo('updates the document if the new id is the same as the old one')
453 453
   })
454 454
   /*
455 455
     We want to be able to use the `document` property to update the

Загрузка…
Отмена
Сохранить