1.0.2 • Published 4 years ago

react-useonload v1.0.2

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

react-useonload

A small, zero dependency React hook that only runs once the component has loaded.

Get

yarn add react-useonload
# or
npm install react-useonload

Use

import useOnload from 'react-useonload'

const App = () => {
  useOnload(() => {
    console.log('this will only run once the component loads')
  })

  // Async callbacks!
  useOnload(async () => {
    await someAsyncFunction()

    console.log('this will only run once the component loads')
  })
}

Fin

by: Jeff Miller https://jamiller.me | hello@jamiller.me