use-good-hooks 1.0.12 → 1.0.14

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 CHANGED
@@ -33,7 +33,7 @@ pnpm add use-good-hooks
33
33
  Debounces value changes to prevent rapid updates. Useful for search inputs, form validation, and other scenarios where you want to delay state updates until after a user has stopped changing the input.
34
34
 
35
35
  ```typescript
36
- import { useDebounce } from 'use-good-hooks';
36
+ import { useDebounce } from 'use-good-hooks/use-debounce';
37
37
 
38
38
  const SearchComponent = () => {
39
39
  const [searchTerm, setSearchTerm] = useState('');
@@ -71,7 +71,7 @@ const SearchComponent = () => {
71
71
  Limits the rate at which a value can update. Useful for scroll events, window resizing, and other high-frequency events.
72
72
 
73
73
  ```typescript
74
- import { useThrottle } from 'use-good-hooks';
74
+ import { useThrottle } from 'use-good-hooks/use-throttle';
75
75
 
76
76
  const ScrollTracker = () => {
77
77
  const [scrollY, setScrollY] = useState(0);
@@ -104,7 +104,7 @@ const ScrollTracker = () => {
104
104
  Captures the previous value of a state or prop. Useful for comparing changes between renders.
105
105
 
106
106
  ```typescript
107
- import { usePrev } from 'use-good-hooks';
107
+ import { usePrev } from 'use-good-hooks/use-prev';
108
108
 
109
109
  const Counter = ({ count }) => {
110
110
  const prevCount = usePrev(count);
@@ -132,7 +132,7 @@ const Counter = ({ count }) => {
132
132
  Detects distinct changes in values with support for deep comparison and custom equality checks. Useful for tracking whether complex objects have actually changed.
133
133
 
134
134
  ```typescript
135
- import { useDistinct } from 'use-good-hooks';
135
+ import { useDistinct } from 'use-good-hooks/use-distinct';
136
136
 
137
137
  const UserProfileForm = ({ user }) => {
138
138
  const { distinct, value, prevValue } = useDistinct(user, { deep: true });
@@ -174,7 +174,7 @@ const UserProfileForm = ({ user }) => {
174
174
  Persists state to localStorage or sessionStorage with automatic serialization/deserialization.
175
175
 
176
176
  ```typescript
177
- import { useStorageState } from 'use-good-hooks';
177
+ import { useStorageState } from 'use-good-hooks/use-storage-state';
178
178
 
179
179
  const ThemePreferences = () => {
180
180
  const [preferences, setPreferences, { removeKey }] = useStorageState('theme-prefs', {
@@ -225,7 +225,7 @@ const ThemePreferences = () => {
225
225
  Synchronizes state with URL query parameters. Great for shareable UI states, filters, pagination, and search terms.
226
226
 
227
227
  ```typescript
228
- import { useUrlState } from 'use-good-hooks';
228
+ import { useUrlState } from 'use-good-hooks/use-url-state';
229
229
 
230
230
  const ProductFilter = () => {
231
231
  const [filters, setFilters] = useUrlState({
@@ -279,7 +279,7 @@ const ProductFilter = () => {
279
279
  Creates and manages global state that can be shared across components with automatic synchronization.
280
280
 
281
281
  ```typescript
282
- import { createGlobalState, useGlobalState } from 'use-good-hooks';
282
+ import { createGlobalState, useGlobalState } from 'use-good-hooks/use-global-state';
283
283
 
284
284
  // Create a global state instance (typically in a separate file)
285
285
  const counterState = createGlobalState({ count: 0 });
@@ -321,7 +321,7 @@ const CounterActions = () => {
321
321
 
322
322
  ```typescript
323
323
  // state/counter.ts
324
- import { createGlobalState } from 'use-good-hooks';
324
+ import { createGlobalState } from 'use-good-hooks/use-global-state';
325
325
 
326
326
  export const counterState = createGlobalState({ count: 0 });
327
327
  ```
@@ -329,7 +329,7 @@ export const counterState = createGlobalState({ count: 0 });
329
329
  2. Then use it in any component:
330
330
 
331
331
  ```typescript
332
- import { useGlobalState } from 'use-good-hooks';
332
+ import { useGlobalState } from 'use-good-hooks/use-global-state';
333
333
  import { counterState } from './state/counter';
334
334
 
335
335
  const MyComponent = () => {
@@ -0,0 +1,7 @@
1
+ export declare type StrictObject = {
2
+ [key: string]: any;
3
+ } & {
4
+ length?: never;
5
+ };
6
+
7
+ export { }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+
@@ -1,11 +1,15 @@
1
- import { StrictObject } from './types';
2
-
3
1
  export declare const jsonReplacer: (key: string, value: any) => any;
4
2
 
5
3
  export declare const jsonReviver: (key: string, value: any) => any;
6
4
 
7
5
  declare type StorageType = 'local' | 'session';
8
6
 
7
+ declare type StrictObject = {
8
+ [key: string]: any;
9
+ } & {
10
+ length?: never;
11
+ };
12
+
9
13
  declare const useStorageState: <T extends StrictObject>(key: string, initialState: T, options?: UseStorageStateOptions) => [T, (value: T | ((prev: T) => T)) => void, {
10
14
  removeKey: () => void;
11
15
  }];
@@ -1,7 +1,11 @@
1
- import { StrictObject } from './types';
2
-
3
1
  declare type SetUrlStateAction<T> = T | ((prevState: T) => T);
4
2
 
3
+ declare type StrictObject = {
4
+ [key: string]: any;
5
+ } & {
6
+ length?: never;
7
+ };
8
+
5
9
  declare const useUrlState: <T extends StrictObject>(initialState: T, options: UseUrlStateOptions) => [T, (value: SetUrlStateAction<T>) => void];
6
10
  export default useUrlState;
7
11
 
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "test": "vitest",
50
50
  "test:coverage": "vitest --coverage"
51
51
  },
52
- "version": "1.0.12"
52
+ "version": "1.0.14"
53
53
  }