diogomoretti / use-reading-time

䷉ A react hook to show in how many time that content could be read

Home Page:https://diogomoretti.github.io/use-reading-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A react hook to show in how many time that content could be read

npm JavaScript Style Guide

View demo ➔


Install

Using Yarn:

yarn add use-reading-time

Using NPM:

npm install --save use-reading-time

Usage

import React, { useRef } from 'react'
import Post from './post'

import useReadingTime from 'use-reading-time'

const Example = () => {
  const post = useRef()
  const {readingTime, wordsCount} = useReadingTime(post)

  return (
    <div>
      {readingTime} min • {wordsCount} words

      // You'll need to use `forwardRef` in this case
      <Post ref={post} />
    </div>
  )
}

Options/Params

useReadingTime(reference, wordsPerMinute)
Argument Description Type Default Required
reference A React ref object Object Yes
wordsPerMinute Number of words we can read per minute Number 260 (Source) No

License

MIT © diogomoretti

About

䷉ A react hook to show in how many time that content could be read

https://diogomoretti.github.io/use-reading-time

License:MIT License


Languages

Language:JavaScript 72.3%Language:CSS 15.1%Language:HTML 12.6%