@codeleap/hooks 6.1.2 → 6.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/hooks",
3
- "version": "6.1.2",
3
+ "version": "6.3.0",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,19 +9,19 @@
9
9
  "directory": "packages/hooks"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/config": "6.1.2",
13
- "@codeleap/types": "6.1.2",
14
- "@codeleap/utils": "6.1.2",
15
- "@codeleap/logger": "6.1.2",
12
+ "@codeleap/config": "6.3.0",
13
+ "@codeleap/types": "6.3.0",
14
+ "@codeleap/utils": "6.3.0",
15
+ "@codeleap/logger": "6.3.0",
16
16
  "ts-node-dev": "1.1.8"
17
17
  },
18
18
  "scripts": {
19
19
  "build": "echo 'No build needed'"
20
20
  },
21
21
  "peerDependencies": {
22
- "@codeleap/types": "6.1.2",
23
- "@codeleap/utils": "6.1.2",
24
- "@codeleap/logger": "6.1.2",
22
+ "@codeleap/types": "6.3.0",
23
+ "@codeleap/utils": "6.3.0",
24
+ "@codeleap/logger": "6.3.0",
25
25
  "axios": "^1.7.9",
26
26
  "typescript": "5.5.2",
27
27
  "react": "19.1.0",
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/hooks",
3
- "version": "6.1.2",
3
+ "version": "6.3.0",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -32,7 +32,6 @@ export * from './usePartialState'
32
32
  export * from './useIsMounted'
33
33
  export * from './useComponentTestId'
34
34
  export * from './useId'
35
- export * from './useAnimatedState'
36
35
  export * from './useDebounceCallback'
37
36
  export * from './useDerivedRef'
38
37
  export * from './useDerivedState'
@@ -1,42 +0,0 @@
1
- import { useState, useCallback } from 'react'
2
- import { SharedValue, useSharedValue, useDerivedValue, runOnJS, isSharedValue } from 'react-native-reanimated'
3
-
4
- /**
5
- * Hook that synchronizes a React state with a Reanimated SharedValue.
6
- *
7
- * @example
8
- * const [value, setValue, sharedValue] = useAnimatedState(0)
9
- * setValue(10) // Updates both React state and SharedValue
10
- */
11
- export function useAnimatedState<T>(initialValue: SharedValue<T> | T) {
12
- const sharedValue = isSharedValue(initialValue)
13
- ? initialValue
14
- : useSharedValue<T>(initialValue)
15
-
16
- const [value, _setValue] = useState<T>(
17
- isSharedValue(initialValue) ? initialValue.value : initialValue,
18
- )
19
-
20
- useDerivedValue(() => {
21
- runOnJS(_setValue)(sharedValue.value)
22
- })
23
-
24
- const setValue = useCallback((newValue: T) => {
25
- sharedValue.value = newValue
26
- if (isSharedValue(initialValue)) initialValue.value = newValue
27
- _setValue(newValue)
28
- }, [])
29
-
30
- return [value, setValue, sharedValue] as const
31
- }
32
-
33
- /**
34
- * Hook that extracts and synchronizes the value from a SharedValue.
35
- *
36
- * @example
37
- * const value = useAnimatedValue(sharedValue)
38
- */
39
- export function useAnimatedValue<T>(initialValue: SharedValue<T> | T): T {
40
- const [value] = useAnimatedState(initialValue)
41
- return value
42
- }