Hooks In React Native

Posted By : Mohd Anas | 21-Dec-2020
 

Hooks are functions that allowed you “hook into” React state and lifecycle hallmarks from function components. Hooks don’t run inside classes — they let you use React without classes.


React presents a few built-in Hooks like useState. You can also build your own Hooks to reuse stateful way between separate components.

 

 

 

 

Hooks allow you to split one component into more modest functions based on what pieces are linked (such as setting up a signature or fetching data), rather than forcing a split based on lifecycle methods.

 

You must have the latest version of NPM and React Native CLI for Using Hooks. This is the command that we need to run in the project root directory to install the hooks dependency 

 

npm install @react-native-community/hooks

 

Installation with yarn

 

yarn add @react-native-community/hooks

 

Here is the list of Apis that is provided by the hooks:

 

Also Read: React Native Complete Installation Guide for Windows

 

useAccessibilityInfo

 

 

 

 

useAppState

 

AppState will vary between one of 'active', 'background', or (iOS) 'inactive' when the app is closed or put into the background.

 

 

useBackHandler

 

 

 

useCameraRoll

 

 

 

useClipboard

 

 

 

useDimensions

 

Gets dimensions and sets up a listener that will switch the dimensions if the user rotates device orientation.

 

 

useImageDimensions

 

 

 

useKeyboard

 

 

 

useInteractionManager

 

 

 

useDeviceOrientation

 

 

 

useLayout

 

 

We, at Oodles Technologies, provide full-scale SaaS app development services to build scalable, responsive, and quality-driven web and mobile applications. Contact us for technical assistance or drop us a line at [email protected] for more detail.

 

References

 

Url : https://github.com/react-native-community/hooks

About Author

Author Image
Mohd Anas

Anas is working as an Android Developer in Oodles Technologies. He is hard working, Self Motivated and dedicated towards his work. He is also passionate about learning new technologies related to our fields.

Request for Proposal

Name is required

Comment is required

Sending message..