npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-use-hooks

v0.0.8

Published

A library of useful React Native hooks.

Readme

React Native Use Hooks

...and some utility functions.

This library is under development, use with caution. More useful hooks coming soon

Import

import { useOrientation } from  'react-native-use-hooks';

useOrientation

It allows you to dynamically retrieve the current orientation of the device screen in a React Native application. Hook returns the string "portrait" or "landscape"

const orientation = useOrientation();

Example

<View>
  {orientation === 'landscape' ? (
	<Text>This content is displayed only in landscape orientation.</Text>
  ) : (
    <Text>This content is displayed in portrait orientation.</Text>
  )}
</View>

getScaledSize function

The getScaledSize function is a utility function that calculates and returns a scaled size for a given input size in a React Native application. It takes into account the screen dimensions and pixel density of the device to ensure consistent sizing across different screens.

Basic usage

const scale = getScaledSize();

And then use it in code or stylesheets

<Text style={{ fontSize: scale(20) }}>
  This text will have a scaled font size of 20 units.
</Text>

Advanced usage

const scale = getScaledSize({size: 20, factor: 0.5, baseWidth: 400});

In this example, the getScaledSize function is called with specific options provided as an argument. However, if the options parameter is not provided, the function will still work and use the default values for size, factor, and baseWidth.

  • size: 20: This option sets the base font size to 20 units. It represents the size that will be scaled based on the device's screen dimensions and pixel density.
  • factor: 0.5: This option determines the scaling factor that will be applied to the base size. In this case, a factor of 0.5 is provided, indicating that the scaled size will be reduced by 50% of the difference between the base size and the calculated size based on the screen dimensions.
  • baseWidth: 400: This option specifies the base width against which the screen dimensions will be compared. It determines the reference width for the scaling calculation.

useTriggerTimer hook

This hook allows you to set a timer and trigger its execution. It returns a tuple containing a boolean value representing the current status of the timer and a function to trigger the timer.

If no time value is provided, the timer functionality will not be triggered. Instead, the status value will always be false, indicating that the timer is inactive.

This hook can be very suitable for displaying tooltips and toasts

Usage

const [status, trigger] = useTriggerTimer(5000);

return (
 <>
   <button onClick={trigger}>Trigger Timer</button>
   {status ? <p>Timer is active.</p> : <p>Timer is inactive.</p>}
 </>
)