1.1.6 • Published 3 years ago

use-assets v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

use-assets

Assets import never been easier 🚀 No more searching for images paths in your project! 🔍🙅🏻‍♂️ useAssets will build assets tree for all the images in your src folder and import it to you automatically with cache

NPM JavaScript Style Guide

Install

npm install --save use-assets

Usage

  1. Put all your images in the src folder (the order don`t matter use as many subdirs as you want)
  2. Make sure all images have unique name (the name of the pic is the key in the assets object)
  3. Enjoy
import * as React from "react";

import { useAssets } from "use-assets";

const Example = () => {
  const { assets, loadingAssets, assetsPaths, assetsTree, assetsError } =
    useAssets();

  if (assetsError) {
    return <span>Error occurred...</span>;
  }

  if (loadingAssets) {
    return <span>Loading assets...</span>;
  }
  return (
    <div>
      <img src={assets.cow} />
    </div>
  );
};

Preview

gh pages (check the example folder in github for reference)

License

MIT © ShaharEli

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago