Skip to content

Commit 9724b18

Browse files
committed
Merge branch 'master' of github.com:prc5/react-zoom-pan-pinch
2 parents 47bd71b + 042c283 commit 9724b18

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./use-controls";
22
export * from "./use-transform-init";
33
export * from "./use-transform-effect";
44
export * from "./use-transform-context";
5+
export * from "./use-transform-component";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useMemo } from "react";
2+
3+
import { useTransformContext } from "./use-transform-context";
4+
import { getState } from "utils";
5+
import { ReactZoomPanPinchContextState } from "../models";
6+
7+
export function useTransformComponent<T>(
8+
callback: (state: ReactZoomPanPinchContextState) => T,
9+
): T {
10+
const libraryContext = useTransformContext();
11+
12+
return useMemo(
13+
() => callback(getState(libraryContext)),
14+
[libraryContext, callback],
15+
);
16+
}

0 commit comments

Comments
 (0)