1.0.11 • Published 3 months ago

use-axios-loader v1.0.11

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

use-axios-loader

use-axios-loader is a tiny React Hook, designed to easily add a loader to all your axios instances.

NPM JavaScript Style Guide

⚙️ Installation

npm install --save use-axios-loader

or

yarn add use-axios-loader

🚀 Usage

import React, { Component } from 'react'
import axiosInstance from 'axios'

import { useAxiosLoader } from 'use-axios-loader'

const MyComponent = () => {
  // Pass the axios instance to the hook
  // Allows you tu customize easily your instance
  const [loading] = useAxiosLoader(axiosInstance)
  return (
    <>
      {loading
      ? <img src="path/to/loader"}/>
      : <div>My data</div>
      }
    </>
  )
}

You may also pass an array of URLs to ignore. This is the second parameter accepted by this hook.

const ignoredUrls = ['https://myignoredurl.com', 'anotherignored.co']
const [loading] = useAxiosLoader(axiosInstance, ignoredUrls)

All urls passed in the ignoredUrls variable, won't trigger the loader.

License

MIT © olivier1208


1.0.11

3 months ago

1.0.10

6 months ago

1.0.9

12 months ago

1.0.8

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.2-beta.2.0

1 year ago

1.0.2-beta.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago