Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prc5/react-zoom-pan-pinch
Browse files Browse the repository at this point in the history
  • Loading branch information
prc5 committed Jun 21, 2024
2 parents 47bd71b + 042c283 commit 9724b18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./use-controls";
export * from "./use-transform-init";
export * from "./use-transform-effect";
export * from "./use-transform-context";
export * from "./use-transform-component";
16 changes: 16 additions & 0 deletions src/hooks/use-transform-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useMemo } 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();

return useMemo(
() => callback(getState(libraryContext)),
[libraryContext, callback],
);
}

0 comments on commit 9724b18

Please sign in to comment.