Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@better-hooks/lifecycle
Advanced tools
React lifecycle turned into dev friendly and readable hooks
🔮 Simple usage
🚀 Fast and light
💎 No external dependencies
🪄 Increases code readability
🎊 SSR Support
npm install --save @better-hooks/lifecycle
or
yarn add @better-hooks/lifecycle
import React from "react";
import {
useDidMount,
useDidUpdate,
useWillUnmount,
useIsMounted,
useWillMount,
useForceUpdate,
useDidChange
} from "@better-hooks/lifecycle";
const MyComponent: React.FC = (props) => {
const [isOpen, setIsOpen] = React.useState(false)
// returns ref with the mounted boolean state
const mounted = useIsMounted()
// Method for the component rerendering
const forceUpdate = useForceUpdate()
// Called before mount
useWillMount(() => {
// ...
})
// Called on component mount
useDidMount(() => {
// ...
})
// Called when isOpen change
useDidUpdate(() => {
// ...
}, [isOpen])
// Called when isOpen change but also on mount
useDidUpdate(() => {
// ...
}, [isOpen], true)
// Called when dependencies change, we can inspect previous dependencies
useDidChange((prevProps) => {
if(prevProps[0].value !== props.value) {
// ...
}
}, [props], true)
// Called last
useWillUnmount(() => {
// ...
})
return (
// ...
)
}
FAQs
React lifecycle turned into dev friendly hooks
The npm package @better-hooks/lifecycle receives a total of 2,288 weekly downloads. As such, @better-hooks/lifecycle popularity was classified as popular.
We found that @better-hooks/lifecycle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.