1.1.0 • Published 9 months ago

use-axios-loader v1.1.0

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

npm.io 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 to ignoredUrls variable, won't trigger the loader.


License

MIT Ā© olivier1208

1.1.0

9 months ago

1.0.15

9 months ago

1.0.14

11 months ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.2-beta.2.0

2 years ago

1.0.2-beta.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago