Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rn-utils

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-utils

React Native Utilities

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

React Native Utils

npm version

React Native Utilities is a package born out of the incessant rewriting of utility functions while developing scalable and maintainable React Native applications. It aims to be a repository that holds trivial yet useful utility functions that are most times copied over/recreated in every new React Native project.

Installation

npm install rn-utils

Utilities

Dimensions
FunctionUsageUtility
getDeviceHeightRNUtils.getDeviceHeight()Returns the device's current viewport height.
getDeviceWidthRNUtils.getDeviceWidth()Returns the device's current viewport width.
Orientation

Currently the only 3rd party package used by React Native Utilities is the React Native Orientation module. If you wish to use any of the Orientation functionalities of React Native Utils, remember to link its native dependencies.

react-native link react-native-orientation
FunctionUsageUtility
addOrientationListenerRNUtils.addOrientationListener((orientation) => this.setState({ orientation }))Creates an event listener that triggers whenever the orientation of the device changes.
getOrientationRNUtils.getOrientation()Function that returns the current device's orientation. It uses getInitialOrientation method from React Native Orientation module to allow for Async/Initial orientation checks. Orientation will either return LANDSCAPE or PORTRAIT.
isLandscapeRNUtils.isLandscape(orientation)Helper that returns true if current device orientation is Landscape. The orientation argument must be passed. This is usually used with the addOrientationListener or getOrientation utility functions.
lockLandscapeRNUtils.lockLandscape()Locks the device's viewport to the Landscape mode. Disables portrait.
lockPortraitRNUtils.lockPortrait()Locks the device's viewport to the Portrait mode. Disables landscape.
unlockOrientationsRNUtils.unlockOrientations()Unlocks any previous locking behavior applied by lockPortrait or lockLandscape.

Roadmap

The aim for this package is to introduce an ever growing list of React Native utilities that can be used when developing real-world scalable applications. With that in mind, below is the list of items I'd like to tackle next. These could be full rewrites of utilities or extracting it from current React Native projects.

  • Font Sizes / Line Heights
  • Legacy Operating Systems
  • Themes (?)
  • Animations (?)

Contributing & PRs

If you believe you have a utility that should be added to this list, please submit a Pull Request and I'll evaluate whether it should be merged. At this moment, I'd like to stay away from integrating other 3rd party libraries that have native dependencies as it creates yet another abstraction on top of those modules (harder to debug).

Issues

If you face issues while using this package, please open an issue on the Issues Tab. I'll try to resolve them as soon as possible.


MIT LICENSED

FAQs

Package last updated on 28 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc