react-useonload

1.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i react-useonload

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

1.34 kB

Total Files

3

Last publish

Collaborators

  • jamiller619