question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Other hooks to make

See original GitHub issue

Description 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.

Application

  • useApplicationInstallTime(): [date]
  • useApplicationAndroidInstallReferrer(): [partialUrl]
  • useApplicationAndroidLastUpdateTime(): [partialUrl]
  • useApplicationIosIdForVendor(options): [id, getId]

Asset

Battery

  • useBattery(): PowerState
  • useBatteryLevel({ listen }): [batteryLevel, isAvailable]
  • useBatteryState({ listen }): [batteryState, isAvailable]
  • useBatteryIsLowPowerMode({ listen }): [isLowPowerMode]

Brightness

  • 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 returning 4.011 quite often for the brightness. This should be 0..1.

Calendar tbd

Camera tbd

Cellular

  • useCellularGeneration: Generation

Contacts

Device

  • useDeviceType(): DeviceType
  • useDeviceUptime(): Number
  • useDeviceMaxMemory(): Number

Location tbd

MediaLibrary tbd

Network

  • useNetworkState(): NetworkState
  • useNetworkIpAddress(): Ip
  • ``

Notifications

  • useNotifications(): notification

Permissions

  • usePermissions(Type, Options): [state, ask, get]

Print (???)

  • usePrint(options): print
  • usePrintToFile(options): file

Random

  • useRandomBytes(options): bytes

ScreenOrientation

  • useScreenOrientation(): orientation
  • useScreenOrientationLock(type, options): [lock, set/unset]

Sensors

  • 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

VideoThumbnails

  • useVideoThumbnail(url, options): [thumbnail, fetch]

WebBrowser

  • useWebBrowser(url, options): [state, open]
  • useWebAuthSession(url, redirect): [state, open]

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sebinsuacommented, Jun 26, 2019

Maybe some kind of useFonts which wraps expo-font?

1reaction
rodw1995commented, May 2, 2020

hasAction internally calls isAvailableAsync if I’m right. So with this it will already skip for web.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found