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

@kevinwolf/use-expo-asset-loader

v1.0.0

Published

React Hook to load and cache assets when using Expo

Downloads

2

Readme

PRs Welcome All Contributors All Contributors Build Status MIT License

version downloads

🎣 @kevinwolf/use-expo-asset-loader

React Hook to load and cache assets when using Expo

The problem

Caching assets in Expo can be a little verbose and repetitive task if you maintain more than one project at the same time.

This solution

This package export a single hook that abstracts the process of preloading and caching the assetts you need on your Expo application.

Installation

This package is distributed via NPM. Install it as a dependency on your project.

yarn add @kevinwolf/use-expo-asset-loader

IMPORTANT: Make sure you have installed react@>=16.8.0 to use React Hooks.

Usage

import React from "react";
import { ScrollView, Text, Image } from "react-native";
import { AppLoading } from "expo";
import useExpoAssetLoader from "@kevinwolf/use-expo-asset-loader";

const images = [
  require("./assets/images/local-image.png"),
  "https://images.pexels.com/photos/2157841/pexels-photo-2157841.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
  "https://images.pexels.com/photos/2108227/pexels-photo-2108227.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260",
  "https://images.pexels.com/photos/2123337/pexels-photo-2123337.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
];

const fonts = {
  roboto: require("./assets/fonts/roboto.ttf")
};

export default function App() {
  const resourceLoader = useAssetLoader({ images, fonts });

  if (!resourceLoader.isReady) {
    return <AppLoading {...resourceLoader.getAppLoadingProps()} />;
  }

  return (
    <ScrollView
      contentInsetAdjustmentBehavior="always"
      contentContainerStyle={{ alignItems: "center", paddingVertical: 20 }}
    >
      <Text style={{ fontFamily: "roboto" }}>Images</Text>
      {images.map(image => (
        <Image
          key={image}
          source={typeof image === "string" ? { uri: image } : image}
          style={{ height: 200, marginTop: 20, width: "100%" }}
        />
      ))}
    </ScrollView>
  );
}

Contributors

If you have any question, suggestion or recommendation, please open an issue about it.

If you decided you want to introduce something to the project, please read the contribution guidelines first.

License

MIT