Other hooks to make
See original GitHub issueDescription of the feature
A list of all Expo features that can be poured into a hook format.
Motivation
I want to implement as many useful hooks as possible, to make the library/repo complete.
Additional context
Best way to get started on the hooks is copying packages/permissions
to packages/<module>
and add all necessary files.
Name should match the Expo module’s name, e.g.
expo-permissions
->packages/permissions
.
-
useApplicationInstallTime(): [date]
-
useApplicationAndroidInstallReferrer(): [partialUrl]
-
useApplicationAndroidLastUpdateTime(): [partialUrl]
-
useApplicationIosIdForVendor(options): [id, getId]
-
Opened PR in Expo itself.useLoadAssets({ fonts, images, ... })
oruseAssets
(source: rockstar wcandillon) -
useLoadFonts(fonts)
oruseFonts
(source: awesome sebinsua)
-
useBattery(): PowerState
-
useBatteryLevel({ listen }): [batteryLevel, isAvailable]
-
useBatteryState({ listen }): [batteryState, isAvailable]
-
useBatteryIsLowPowerMode({ listen }): [isLowPowerMode]
-
useBrightness(Options): [brightness, set, get]
-
useSystemBrightness(Options): [brightness, set, get]
-
useSystemBrightnessMode(Options): [mode, set, get]
todo: help update the docs with the new
...Async
methods Right now, the brightness mode isn’t documented at all. We need to fix that 😁. There also might be a bug with the brightness amount on Android (OnePlus 6), it’s returning4.011
quite often for the brightness. This should be0..1
.
Calendar tbd
Camera tbd
-
useCellularGeneration: Generation
-
useContacts
- as described by Janic Duplessis
-
useDeviceType(): DeviceType
-
useDeviceUptime(): Number
-
useDeviceMaxMemory(): Number
Location tbd
MediaLibrary tbd
-
useNetworkState(): NetworkState
-
useNetworkIpAddress(): Ip
- ``
-
useNotifications(): notification
-
usePermissions(Type, Options): [state, ask, get]
Print (???)
-
usePrint(options): print
-
usePrintToFile(options): file
-
useRandomBytes(options): bytes
-
useScreenOrientation(): orientation
-
useScreenOrientationLock(type, options): [lock, set/unset]
-
useAccelerometer(options): data
-
useBarometer(options): data
-
useDeviceMotion(options): data
-
useGyroscope(options): data
-
useMagnetometer(options): data
-
useMagnetometerUncalibrated(options): data
-
usePedometer(options): data
-
usePedometerHistory(options): data
StoreReview tbd
Updates tbd
-
useVideoThumbnail(url, options): [thumbnail, fetch]
-
useWebBrowser(url, options): [state, open]
-
useWebAuthSession(url, redirect): [state, open]
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Building Your Own Hooks - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. Building your...
Read more >How to create your own custom React Hooks - LogRocket Blog
With custom React Hooks, we can reuse stateful logic easily across different components in an optimized and scalable format.
Read more >useHooks - Easy to understand React Hook recipes
We bring you easy to understand React Hook code recipes so you can learn how React hooks work and feel more comfortable writing...
Read more >The Guide to Learning React Hooks (Examples & Tutorials)
Learn all about React Hooks with this hands-on guide. Includes tutorials and code examples on using hooks for state and effects, for context...
Read more >React: How to create a Custom Hook - Robin Wieruch
Custom Hooks consist of built-in React Hooks or other custom Hooks. Therefore a custom Hook is always a new composition of one or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe some kind of
useFonts
which wrapsexpo-font
?hasAction
internally callsisAvailableAsync
if I’m right. So with this it will already skip for web.