Current collected state Current
Observed since 20 Oct, 21:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
React useUnmounted hook
useUnmounted hookdo async operations in useEffect, and set state safety
import { useUnmounted } from '@-ft/use-unmounted';
function MyComponent() {
const unmountedPersist = useUnmounted();
const [state, setState] = useState("Loading...");
useEffect(() => {
(async () => {
const result = await fetchSomething();
if (unmountedPersist.current) {
// if the component is unmounted, setState is not safe
return;
}
setState(result);
})();
}, [unmountedPersist, setState]);
return <div>{state}</div>;
}
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0Registry latest | 22 Sept 2023 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:49 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:f83f6ac4b357a74b16074e9e2a60aba93467d722d6a12965466c09d159500d5a