File tree Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.3.2
2
+
3
+ - Fix: Invalid hook call ([ #14 ] ( https://github.com/logicwind/react-native-fold-detection/issues/14 ) )
4
+
5
+ ## 0.3.1
6
+
7
+ - Fix: Ios build issue on react-native version 0.76.0
8
+
9
+ ## 0.3.0
10
+
11
+ - Fixed null pointer exception error on startListener.
12
+ - Added detection for only fold devices will register for the listener.
13
+
14
+ ## 0.2.0
15
+
16
+ - Read me updated
17
+ - Example updated
18
+
19
+ ## 0.1.0
20
+
21
+ - Initial Release
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @logicwind/react-native-fold-detection" ,
3
- "version" : " 0.3.1 " ,
3
+ "version" : " 0.3.2 " ,
4
4
"description" : " The purpose of the package is to provide details regarding the Android folding capability." ,
5
5
"main" : " lib/commonjs/index" ,
6
6
"module" : " lib/module/index" ,
170
170
]
171
171
]
172
172
}
173
- }
173
+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export const FoldingFeatureContext = createContext<FoldingFeatureContextProps>({
38
38
} ) ;
39
39
40
40
export const useFoldingFeature = ( ) => {
41
+ const context = useContext ( FoldingFeatureContext ) ;
42
+
43
+ if ( context === undefined ) {
44
+ throw new Error ( 'useFoldingFeature was used outside of its provider' ) ;
45
+ }
46
+
41
47
if ( Platform . OS === 'ios' ) {
42
48
return {
43
49
layoutInfo : { } ,
@@ -46,20 +52,16 @@ export const useFoldingFeature = () => {
46
52
isFlat : true ,
47
53
} ;
48
54
}
49
- const context = useContext ( FoldingFeatureContext ) ;
50
-
51
- if ( context === undefined ) {
52
- throw new Error ( 'useFoldingFeature was used outside of its provider' ) ;
53
- }
54
-
55
+
55
56
return context ;
56
57
} ;
57
58
58
59
export const FoldingFeatureProvider = ( { children } : PropsWithChildren < { } > ) => {
60
+ const value = useProvideFunc ( ) ;
61
+
59
62
if ( Platform . OS === 'ios' ) {
60
63
return children ;
61
64
}
62
- const value = useProvideFunc ( ) ;
63
65
64
66
return (
65
67
< FoldingFeatureContext . Provider value = { value } >
@@ -100,6 +102,10 @@ const useProvideFunc = (): FoldingFeatureContextProps => {
100
102
} , [ isTableTop , isBook ] ) ;
101
103
102
104
useEffect ( ( ) => {
105
+ if ( Platform . OS === 'ios' ) {
106
+ return ; // Just return early from the effect
107
+ }
108
+
103
109
FoldingFeature . startListening ( ) ;
104
110
105
111
const eventEmitter = new NativeEventEmitter ( ) ;
You can’t perform that action at this time.
0 commit comments