@@ -15,17 +15,16 @@ npm install @react-native-community/hooks
1515```
1616
1717Installation with yarn
18+
1819``` sh
1920yarn add @react-native-community/hooks
2021```
2122
2223## API
24+
2325- [ useAccessibilityInfo] ( https://github.com/react-native-community/hooks#useaccessibilityinfo )
2426- [ useAppState] ( https://github.com/react-native-community/hooks#useappstate )
2527- [ useBackHandler] ( https://github.com/react-native-community/hooks#usebackhandler )
26- - ~~ [ useCameraRoll] ( https://github.com/react-native-community/hooks#usecameraroll ) ~~
27- - ~~ [ useClipboard] ( https://github.com/react-native-community/hooks#useclipboard ) ~~
28- - [ useDimensions] ( https://github.com/react-native-community/hooks#usedimensions )
2928- [ useImageDimensions] ( https://github.com/react-native-community/hooks#useImageDimensions )
3029- [ useKeyboard] ( https://github.com/react-native-community/hooks#usekeyboard )
3130- [ useInteractionManager] ( https://github.com/react-native-community/hooks#useinteractionmanager )
@@ -35,15 +34,15 @@ yarn add @react-native-community/hooks
3534### ` useAccessibilityInfo `
3635
3736``` js
38- import { useAccessibilityInfo } from ' @react-native-community/hooks'
37+ import {useAccessibilityInfo } from ' @react-native-community/hooks'
3938
4039const {
4140 boldTextEnabled ,
4241 screenReaderEnabled ,
4342 reduceMotionEnabled , // requires RN60 or newer
4443 grayscaleEnabled, // requires RN60 or newer
4544 invertColorsEnabled, // requires RN60 or newer
46- reduceTransparencyEnabled // requires RN60 or newer
45+ reduceTransparencyEnabled, // requires RN60 or newer
4746} = useAccessibilityInfo ()
4847```
4948
@@ -52,15 +51,15 @@ const {
5251AppState will change between one of 'active', 'background', or (iOS) 'inactive' when the app is closed or put into the background.
5352
5453``` js
55- import { useAppState } from ' @react-native-community/hooks'
54+ import {useAppState } from ' @react-native-community/hooks'
5655
5756const currentAppState = useAppState ()
5857```
5958
6059### ` useBackHandler `
6160
6261``` js
63- import { useBackHandler } from ' @react-native-community/hooks'
62+ import {useBackHandler } from ' @react-native-community/hooks'
6463
6564useBackHandler (() => {
6665 if (shouldBeHandledHere) {
@@ -72,50 +71,6 @@ useBackHandler(() => {
7271})
7372```
7473
75- ### ` useCameraRoll `
76-
77- ⚠️ ** Deprecated** . Please use ` useCameraRoll() ` from [ ` @react-native-camera-roll/camera-roll ` ] ( https://github.com/react-native-cameraroll/react-native-cameraroll#usecameraroll )
78-
79- ``` js
80- import { useCameraRoll } from ' @react-native-community/hooks'
81-
82- const [photos , getPhotos , saveToCameraRoll ] = useCameraRoll ()
83-
84- {
85- photos .map ((photo , index ) => /* render photos */ )
86- }
87-
88- < Button title= ' Get Photos' onPress= {() => getPhotos ()}> Get Photos< / Button>
89- ```
90-
91- ### ` useClipboard `
92-
93- ⚠️ ** Deprecated** . Please use ` useClipboard() ` from [ ` @react-native-clipboard/clipboard ` ] ( https://github.com/react-native-clipboard/clipboard#useclipboard )
94-
95- ``` js
96- import { useClipboard } from ' @react-native-community/hooks'
97-
98- const [data , setString ] = useClipboard ()
99-
100- < Text > {data}< / Text >
101-
102- < Button title= ' Update Clipboard' onPress= {() => setString (' new clipboard data' )}> Set Clipboard< / Button>
103- ```
104-
105- ### ` useDimensions `
106-
107- Gets dimensions and sets up a listener that will change the dimensions if the user changes device orientation.
108-
109- ``` js
110- import { useDimensions } from ' @react-native-community/hooks'
111-
112- const dimensions = useDimensions ()
113- // or
114- const { width , height } = useDimensions ().window
115- // or
116- const screen = useDimensions ().screen
117- ```
118-
11974### ` useImageDimensions `
12075
12176``` js
@@ -127,7 +82,7 @@ const source = {uri: 'https://your.image.URI'}
12782
12883const {dimensions , loading , error } = useImageDimensions (source)
12984
130- if (loading || error || ! dimensions) {
85+ if (loading || error || ! dimensions) {
13186 return null
13287}
13388const {width , height , aspectRatio } = dimensions
@@ -136,7 +91,7 @@ const {width, height, aspectRatio} = dimensions
13691### ` useKeyboard `
13792
13893``` js
139- import { useKeyboard } from ' @react-native-community/hooks'
94+ import {useKeyboard } from ' @react-native-community/hooks'
14095
14196const keyboard = useKeyboard ()
14297
@@ -147,7 +102,7 @@ console.log('keyboard keyboardHeight: ', keyboard.keyboardHeight)
147102### ` useInteractionManager `
148103
149104``` js
150- import { useInteractionManager } from ' @react-native-community/hooks'
105+ import {useInteractionManager } from ' @react-native-community/hooks'
151106
152107const interactionReady = useInteractionManager ()
153108
@@ -157,12 +112,11 @@ console.log('interaction ready: ', interactionReady)
157112### ` useDeviceOrientation `
158113
159114``` js
160- import { useDeviceOrientation } from ' @react-native-community/hooks'
115+ import {useDeviceOrientation } from ' @react-native-community/hooks'
161116
162117const orientation = useDeviceOrientation ()
163118
164- console .log (' is orientation portrait: ' , orientation .portrait )
165- console .log (' is orientation landscape: ' , orientation .landscape )
119+ console .log (' orientation is:' , orientation)
166120```
167121
168122### ` useLayout `
0 commit comments