diff --git a/README.md b/README.md index 928041f..4dd33b1 100644 --- a/README.md +++ b/README.md @@ -91,76 +91,39 @@ or ```jsx import React, { Component } from "react"; -import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; - -const Example = () => { - return ( - - {({ zoomIn, zoomOut, resetTransform, ...rest }) => ( - -
- - - -
- - test -
Example text
-
-
- )} -
- ); -}; -``` - -or - -```tsx -import React, { useRef } from "react"; import { TransformWrapper, TransformComponent, - ReactZoomPanPinchRef, + useControls, } from "react-zoom-pan-pinch"; -const Controls = ({ zoomIn, zoomOut, resetTransform }) => ( - <> - - - - -); - -const Component = () => { - const transformComponentRef = useRef(null); +const Controls = () => { + const { zoomIn, zoomOut, resetTransform } = useControls(); - const zoomToImage = () => { - if (transformComponentRef.current) { - const { zoomToElement } = transformComponentRef.current; - zoomToElement("imgExample"); - } - }; + return ( +
+ + + +
+ ); +}; +const Example = () => { return ( - {(utils) => ( - - + {({ zoomIn, zoomOut, resetTransform, ...rest }) => ( + <> + - test -
Example text
+ test +
Example text
-
+ )}
);