(el: React.Element<*>)
| 55 | }; |
| 56 | |
| 57 | export const create = (el: React.Element<*>) => { |
| 58 | const container = document.createElement("div"); |
| 59 | const root = createRoot(container); |
| 60 | let instance = null; |
| 61 | |
| 62 | function render(element) { |
| 63 | flushSync(() => { |
| 64 | root.render( |
| 65 | React.cloneElement(element, { |
| 66 | ref: (r) => { |
| 67 | instance = r; |
| 68 | }, |
| 69 | }) |
| 70 | ); |
| 71 | }); |
| 72 | } |
| 73 | |
| 74 | render(el); |
| 75 | |
| 76 | return { |
| 77 | getInstance: () => instance, |
| 78 | update: (newEl) => render(newEl), |
| 79 | unmount: () => { |
| 80 | flushSync(() => root.unmount()); |
| 81 | }, |
| 82 | }; |
| 83 | }; |
| 84 | |
| 85 | type SurfaceCounters = { |
| 86 | onSurfaceDrawEnd: number, |
searching dependent graphs…