🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

use-hot-module-reload

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-hot-module-reload

React hook that triggers a callback after hot-module reloading has been performed (for any module, not just the one it was used in)

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
454K
6%
Maintainers
1
Weekly downloads
 
Created
Source

use-hot-module-reload

React hook that triggers a callback after hot-module reloading has been performed (for any module, not just the one it was used in).

Works with modern versions of Webpack and Vite. Other bundlers may be added if they expose a way to listen for updates.

Installation

npm install --save use-hot-module-reload

Usage

import {useState, useCallback} from 'react'
import {useHotModuleReload} from 'use-hot-module-reload'

export function MyComponent() {
  const [lastHMRed, setLastHMRed] = useState('')
  const updateHMRTime = useCallback(() => setLastHMRed(new Date().toISOString()), [])
  useHotModuleReload(updateHMRTime)

  return <div>{lastHMRed && `Last hot module reload at: ${lastHMRed}`}</div>
}

License

MIT © Espen Hovlandsdal

Keywords

hmr

FAQs

Package last updated on 22 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts