File tree Expand file tree Collapse file tree 3 files changed +191
-137
lines changed Expand file tree Collapse file tree 3 files changed +191
-137
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Collection of React Hooks used by [Charlie Tango](https://www.charlietango.dk/).
88- Written in TypeScript, with full types support.
99- Small and focused, each hook does one thing well.
1010- No barrel file, only import the hooks you need.
11+ - Exported as ESM.
1112- Optimized for modern React, uses newer APIs like ` useSyncExternalStore ` .
1213- All hooks work in a server-side rendering environment.
1314- All hooks are tested with [ Vitest] ( https://vitest.dev/ ) in a real browser environment.
@@ -69,6 +70,8 @@ const prefersReducedMotion = useMedia(
6970Keep track of the previous value of a variable.
7071
7172``` ts
73+ import { usePrevious } from " @charlietango/hooks/use-previous" ;
74+
7275const prevValue = usePrevious (value );
7376```
7477
@@ -81,6 +84,8 @@ The `useScript` hook will handle this for you.
8184You can load the same script multiple times, and the hook will share the script and status between all instances.
8285
8386``` ts
87+ import { useScript } from " @charlietango/hooks/use-script" ;
88+
8489const status = useScript (" https://example.com/script.js" ); // "idle" | "loading" | "ready" | "error"
8590if (status === " ready" ) {
8691 // Script is loaded
Original file line number Diff line number Diff line change 5959 "@vitest/browser" : " ^2.0.4" ,
6060 "bumpp" : " ^9.4.1" ,
6161 "globby" : " ^14.0.2" ,
62- "husky" : " ^9.1.1 " ,
62+ "husky" : " ^9.1.3 " ,
6363 "lint-staged" : " ^15.2.7" ,
64- "playwright" : " ^1.45.2 " ,
64+ "playwright" : " ^1.45.3 " ,
6565 "prettier" : " ^3.3.3" ,
6666 "react" : " ^18.0.0" ,
6767 "react-dom" : " ^18.0.0" ,
6868 "size-limit" : " ^11.1.4" ,
69- "tsup" : " ^8.2.2 " ,
70- "typescript" : " ^5.5.3 " ,
69+ "tsup" : " ^8.2.3 " ,
70+ "typescript" : " ^5.5.4 " ,
7171 "vitest" : " ^2.0.4"
7272 },
7373 "packageManager" :
" [email protected] +sha256.dae0f7e822c56b20979bb5965e3b73b8bdabb6b8b8ef121da6d857508599ca35"
You can’t perform that action at this time.
0 commit comments