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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@luckypear/react-native-thumbhash

v1.0.2

Published

A very compact representation of an image placeholder for react native

Downloads

670

Readme

react-native-thumbhash

A very compact representation of an image placeholder for react native

What is thumbhash?

thumbhash is a A very compact representation of a placeholder for an image. Store it inline with your data and show it while the real image is loading for a smoother loading experience.

To know more about thumbhash click here.

I recommend you to have a pre-encoded thumbhash string and store it in your server. And when your server delivers an image, you can add thumbhash in your payload. You can now immediately show <Thumbhash> component before your Image component finishes loading.

Installation

yarn add @luckypear/react-native-thumbhash

or

npm install @luckypear/react-native-thumbhash

ios

npx pod-install

you will need pod install

android

no extra steps are needed

Usage

The <Blurhash> component has the following properties:

Example

import { Thumbhash } from '@luckypear/react-native-thumbhash';

// ...

<Thumbhash thumbhash="3OcRJYB4d3h/iIeHeEh3eIhw+j2w" />;

Encoding

You can encode with this library and generate your thumbhash in your app.

const thumbhash = await Thumbhash.encode('https://picsum.photos/200');

encode method loads image via react-native image loader, and scales it and encodes it in to a thumbhash string. And this means it is a time taking task so you should be aware of using it.

If you want to encode it in your react-native app, I recommend you a tip that you can use thumbhash string to file name that you will set to server (presigned url or cdn or whatever). then you can just make your own Image component to extract the file name(which is a thumbhash string) and display it before you load your image. this will save some bytes for your playload :)

Features

  • [x] thumbhash rendering (decoding)
  • [x] new arch/old arch support
  • [x] async dencoding
  • [x] thumbhash encoding
  • [x] resizeMode support

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Resources