@dhruv-m-patel/react-hooks
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@dhruv-m-patel/react-hooks

A library of custom react hooks for frontend projects

CI Status

Using this package

  1. Install this package

    npm i -S @dhruv-m-patel/react-hooks
    # OR
    yarn add @dhruv-m-patel/react-hooks
  2. Import custom hook from this package and use it in your component

    import * as React from 'react';
    import { useFetch } from '@dhruv-m-patel/react-hooks';
    import { Text } from '@dhruv-m-patel/react-components';
    
    export default function MyAwesomeComponent({ apiEndpoint }) {
      const { loading, error, data } = useFetch(apiEndpoint);
    
      if (loading) {
        return (
          <Text>Loading data....</Text>
        );
      }
    
      if (error) {
        return (
          <Text>Oops, There was an error fetching data!</Text>
        );
      }
    
      return (
        <Text>{JSON.stringify(data)}</Text>
      );
    }

Readme

Keywords

Package Sidebar

Install

npm i @dhruv-m-patel/react-hooks

Weekly Downloads

11

Version

1.3.0

License

MIT

Unpacked Size

47.6 kB

Total Files

57

Last publish

Collaborators

  • dhruv-m-patel