
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
react-use-lifecycle-helpers
Advanced tools
Helpers functions arround useEffect hook to make your life easier, providing the most use cases of useEffect hook, among them the lifecycle of class component.
Helpers functions arround useEffect hook to make your life easier, providing the most use cases of useEffect hook, among them the lifecycle of class component.
npm install --save react-use-lifecycle-helpers
useDidMountThis hook is a replacement for the componentDidMount method.
import useLifecycleMethods from "react-use-lifecycle-helpers";
export default function MyComponent() {
const { useDidMount } = useLifecycleMethods();
useDidMount(() => {
console.log("MyComponent is mounted");
});
}
useDidUpdateThis hook is similar to the componentDidUpdate method.
import useLifecycleMethods from "react-use-lifecycle-helpers";
export default function MyComponent(props) {
const [state, setState] = useState({ count: 0, bool: false });
const { useDidUpdate } = useLifecycleMethods(state, props);
useDidUpdate(() => {
console.log("MyComponent is updated");
});
}
useWillUnmountA hook that's a replacement for the componentWillUnmount method.
import useLifecycleMethods from "react-use-lifecycle-helpers";
export default function MyComponent() {
const { useWillUnmount } = useLifecycleMethods();
useWillUnmount(() => {
console.log("MyComponent will unmount");
});
}
useDepsDidChangeTrack multiple or one of the state properties.
import useLifecycleMethods from "react-use-lifecycle-helpers";
export default function MyComponent(props) {
const [state, setState] = useState({ count: 0, bool: false });
const { useDepsDidChange } = useLifecycleMethods(state, props);
useDepsDidChange(
prevState => {
console.log("useDepsDidChange Count", state.count, prevState.count);
},
["count"]
);
useDepsDidChange(
prevState => {
console.log("useDepsDidChange Bool", state.bool, prevState.bool);
},
["bool"]
);
useDepsDidChange(
prevState => {
console.log("useDepsDidChange Count", state.count, prevState.count);
console.log("useDepsDidChange Bool", state.bool, prevState.bool);
},
["bool", "count"]
);
}
MIT © [Mohcine NAZRHAN](https://github.com/Mohcine NAZRHAN)
FAQs
Helpers functions arround useEffect hook to make your life easier, providing the most use cases of useEffect hook, among them the lifecycle of class component.
The npm package react-use-lifecycle-helpers receives a total of 1 weekly downloads. As such, react-use-lifecycle-helpers popularity was classified as not popular.
We found that react-use-lifecycle-helpers demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.