Buckets:
Quantumbraid/trainingdata / ui /node_modules /react-zoom-pan-pinch /src /hooks /use-transform-component.tsx
| import { useEffect, useState } from "react"; | |
| import { useTransformContext } from "./use-transform-context"; | |
| import { getState } from "utils"; | |
| import { ReactZoomPanPinchContextState } from "../models"; | |
| export function useTransformComponent<T>( | |
| callback: (state: ReactZoomPanPinchContextState) => T, | |
| ): T { | |
| const libraryContext = useTransformContext(); | |
| const [transformRender, setTransformRender] = useState<T>( | |
| callback(getState(libraryContext)), | |
| ); | |
| useEffect(() => { | |
| let mounted = true; | |
| const unmount = libraryContext.onChange((ref) => { | |
| if (mounted) { | |
| setTransformRender(callback(getState(ref.instance))); | |
| } | |
| }); | |
| return () => { | |
| unmount(); | |
| mounted = false; | |
| }; | |
| }, [callback, libraryContext]); | |
| return transformRender; | |
| } | |
Xet Storage Details
- Size:
- 792 Bytes
- Xet hash:
- 747bae01c7def8b9a4ff73879a5fb7203d50e433531c17a917933173632667ea
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.