@prtcl/plonk-hooks 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @prtcl/plonk-hooks
|
|
2
2
|
|
|
3
|
-
React hook wrappers for [`@prtcl/plonk`](https://www.npmjs.com/package/@prtcl/plonk). Manages timer lifecycle on mount/unmount
|
|
3
|
+
React hook wrappers for [`@prtcl/plonk`](https://www.npmjs.com/package/@prtcl/plonk). Manages timer lifecycle on mount/unmount and provides memoized instances of plonk's generators for use in components.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,21 +12,21 @@ Requires React 17–19 as a peer dependency.
|
|
|
12
12
|
|
|
13
13
|
## Hooks
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
**Timers** — `useMetro`, `useFrames` — lifecycle-managed timer loops
|
|
16
|
+
|
|
17
|
+
**Generators** — `useDrunk`, `useRand`, `useEnv`, `useSine`, `useScale`, `useFold`, `useWrap` — memoized instances of the corresponding plonk classes
|
|
18
|
+
|
|
19
|
+
**Utilities** — `usePrevious` — tracks the previous value of a variable
|
|
18
20
|
|
|
19
21
|
## Quick example
|
|
20
22
|
|
|
21
23
|
```typescript
|
|
22
24
|
import { useRef } from 'react';
|
|
23
|
-
import {
|
|
24
|
-
import { useFrames } from '@prtcl/plonk-hooks';
|
|
25
|
-
|
|
26
|
-
const env = new Env({ duration: 2000, from: 0, to: 1 });
|
|
25
|
+
import { useFrames, useEnv } from '@prtcl/plonk-hooks';
|
|
27
26
|
|
|
28
27
|
function FadeIn({ children }) {
|
|
29
28
|
const ref = useRef(null);
|
|
29
|
+
const env = useEnv({ duration: 2000, from: 0, to: 1 });
|
|
30
30
|
|
|
31
31
|
const frames = useFrames(() => {
|
|
32
32
|
if (ref.current) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prtcl/plonk-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "React hook wrappers for plonk",
|
|
5
5
|
"author": "Cory O'Brien <cory@prtcl.cc>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "vitest --browser.name=chrome --browser.headless --watch=false"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@prtcl/plonk": "1.
|
|
26
|
+
"@prtcl/plonk": "1.4.0",
|
|
27
27
|
"client-only": "^0.0.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|