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 11{
22 "name" : " @logicwind/react-native-fold-detection" ,
3- "version" : " 0.3.1 " ,
3+ "version" : " 0.3.2 " ,
44 "description" : " The purpose of the package is to provide details regarding the Android folding capability." ,
55 "main" : " lib/commonjs/index" ,
66 "module" : " lib/module/index" ,
170170 ]
171171 ]
172172 }
173- }
173+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export const FoldingFeatureContext = createContext<FoldingFeatureContextProps>({
3838} ) ;
3939
4040export 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+
4147 if ( Platform . OS === 'ios' ) {
4248 return {
4349 layoutInfo : { } ,
@@ -46,20 +52,16 @@ export const useFoldingFeature = () => {
4652 isFlat : true ,
4753 } ;
4854 }
49- const context = useContext ( FoldingFeatureContext ) ;
50-
51- if ( context === undefined ) {
52- throw new Error ( 'useFoldingFeature was used outside of its provider' ) ;
53- }
54-
55+
5556 return context ;
5657} ;
5758
5859export const FoldingFeatureProvider = ( { children } : PropsWithChildren < { } > ) => {
60+ const value = useProvideFunc ( ) ;
61+
5962 if ( Platform . OS === 'ios' ) {
6063 return children ;
6164 }
62- const value = useProvideFunc ( ) ;
6365
6466 return (
6567 < FoldingFeatureContext . Provider value = { value } >
@@ -100,6 +102,10 @@ const useProvideFunc = (): FoldingFeatureContextProps => {
100102 } , [ isTableTop , isBook ] ) ;
101103
102104 useEffect ( ( ) => {
105+ if ( Platform . OS === 'ios' ) {
106+ return ; // Just return early from the effect
107+ }
108+
103109 FoldingFeature . startListening ( ) ;
104110
105111 const eventEmitter = new NativeEventEmitter ( ) ;
You can’t perform that action at this time.
0 commit comments