1.2.0 • Published 3 years ago

usegoodreads v1.2.0

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

useGoodreads

A react hook to get your Goodreads data. Strongly typed using Typescript.

Installation

   // yarn
   yarn add usegoodreads

   // npm
   npm i usegoodreads

Usage

// Require the module
import { useGoodreads } from 'usegoodreads';

const App = () => {
  const { fetchBooks, loading, data } = useGoodreads({
    userId: 'your-user-id',
    shelf: 'currenty-reading',
  });

  useEffect(() => {
    // use the callback to retrieve data from Goodreads
    fetchBooks();
  }, []);
  
  return (
    <div>
        <ul>
          {data?.map(b => (
            // render your UI with your Goodreads data!
          ))}
        </ul>
    </div>
  );
};

Props

PropTypeOptionalDefaultDescription
userIdstringNoundefinedRequired to get the books data from the user
shelfstringYes'read'Based on the default shelf from Goodreads, which are 'read', 'currently-reading' or 'to-read'
customShelfstringYesundefinedUsed to retrieve shelfs created by the user. This overrides the value from the 'shelf' property

Example

Refer to the example folder to find an implementation of this project