-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added docs for useTransformComponent and fixed the hook to updat…
…e on context change (#480) Co-authored-by: Tyler <[email protected]>
- Loading branch information
1 parent
9724b18
commit 16e1466
Showing
5 changed files
with
127 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Meta } from "@storybook/addon-docs/blocks"; | ||
|
||
<Meta title="Hooks/useTransformComponent" /> | ||
|
||
# useTransformComponent | ||
|
||
This hooks allows to easily connect with lifecycle into the Zoom-Pan-Pinch state | ||
for rendering a component. It will trigger the provided callback every time the | ||
transform state is changed. | ||
|
||
It will not affect rerendering so you can control the way you use received data. | ||
|
||
### Example | ||
|
||
```tsx | ||
const App = () => { | ||
// It will trigger every time you interact with transform-component | ||
// At the same time it will not cause rerendering so you can control it on your own | ||
const transformedComponent = useTransformComponent(({ state, instance }) => { | ||
console.log(state); // { previousScale: 1, scale: 1, positionX: 0, positionY: 0 } | ||
|
||
return <div>Current scale: {state.scale}</div>; | ||
}); | ||
|
||
return transformedComponent; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters