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 }) => ( - - - zoomIn()}>+ - zoomOut()}>- - resetTransform()}>x - - - - Example text - - - )} - - ); -}; -``` - -or - -```tsx -import React, { useRef } from "react"; import { TransformWrapper, TransformComponent, - ReactZoomPanPinchRef, + useControls, } from "react-zoom-pan-pinch"; -const Controls = ({ zoomIn, zoomOut, resetTransform }) => ( - <> - zoomIn()}>+ - zoomOut()}>- - resetTransform()}>x - > -); - -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 ( + + zoomIn()}>+ + zoomOut()}>- + resetTransform()}>x + + ); +}; +const Example = () => { return ( - {(utils) => ( - - + {({ zoomIn, zoomOut, resetTransform, ...rest }) => ( + <> + - - Example text + + Example text - + > )} );