
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
use-effect-event
Advanced tools
Ponyfill of the experimental
React.useEffectEvent
hook
[!IMPORTANT] Make sure you read about the limitations and understand them before you start using this hook, it's not a silver bullet.
This package implements the same API as the experimental React.useEffectEvent
hook, based on its implementation in Bluesky.
The only difference is that instead of installing an experimental build of React, you can use this package as a ponyfill. Here's an example, from the official docs, that shows how it can be used to log whenever url
changes, and still access the latest value of numberOfItems
without needing to resort to useRef
proxying:
// import {useEffectEvent} from 'react'
import {useEffectEvent} from 'use-effect-event'
function Page({url}) {
const {items} = useContext(ShoppingCartContext)
const numberOfItems = items.length
const onVisit = useEffectEvent((visitedUrl) => {
logVisit(visitedUrl, numberOfItems)
})
useEffect(() => {
onVisit(url)
}, [url])
}
FAQs
Ponyfill of the experimental `React.useEffectEvent` hook
The npm package use-effect-event receives a total of 124,267 weekly downloads. As such, use-effect-event popularity was classified as popular.
We found that use-effect-event demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.