
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@react-hookbox/immediate-effect
Advanced tools
To use immediate effect, you need to import the `useImmediateEffectDangerously` hook from the `@react-hookbox/immediate-effect` module.
To use immediate effect, you need to import the useImmediateEffectDangerously hook from the @react-hookbox/immediate-effect module.
import { useImmediateEffectDangerously } from '@react-hookbox/immediate-effect';
Make sure that all operations inside useImmediateEffectDangerously are synchronous, hence some actions might end up in an error if they cause a re-render.
import { useRef, EffectCallback } from 'react';
import { assertDepsValidity } from './utils/assert-deps-validity';
export const assertDepsValidity: (deps: unknown) => asserts deps is unknown[] = (deps: unknown) => {
if (deps === undefined) {
throw new Error('useImmediateEffect: deps must be provided')
}
if (!Array.isArray(deps)) {
throw new Error('useImmediateEffect: deps must be an array')
}
};
export const useImmediateEffectDangerously = (
effectCallback: EffectCallback,
deps: unknown[]
): void => {
assertDepsValidity(deps);
const depsRef = useRef(deps);
const destructureCallbackRef = useRef<ReturnType<EffectCallback>>();
if (depsRef.current.length !== deps.length) {
throw new Error(
'useImmediateEffectDangerously: deps length must not change'
);
}
if (depsRef.current.every((dep, index) => dep === deps[index])) {
return;
}
depsRef.current = deps;
destructureCallbackRef.current?.();
const destructureCallback = effectCallback();
destructureCallbackRef.current = destructureCallback;
};
FAQs
To use immediate effect, you need to import the `useImmediateEffectDangerously` hook from the `@react-hookbox/immediate-effect` module.
We found that @react-hookbox/immediate-effect demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.