0.0.6 • Published 3 years ago

use-constructor-hook v0.0.6

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

useConstructor NPM version npm GitHub stars

useConstructor is a custom hook for do something before the first component render

Installation

npm install --save use-constructor-hook

Example:

import React, { useState } from 'react'
import { useConstructor } from 'use-constructor-hook'

import { fetchDataFromApi } from './api.js'

const App = () => {
  const [dataFetched, setDataFetched] = useState(undefined)
  useConstructor(async () => {
    const response = await fetchDataFromApi()
  })

  return (
    <div>{dataFetched || 'Loading data...'}<div>
  )
}

Support

Submit an issue

Credits

0.0.5

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago