
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.
@xiel/outer-hooks
Advanced tools
Create function components using powerful and composable hooks.
If you know and love hooks from React, you already know the main API of OuterHooks as they are very alike.
yarn add @xiel/outer-hooks
This library is still in beta. It works, is well tested and actively being developed. But the API is not 100% stable yet.
For now please check the React Hooks API reference as they work exactly the same in OuterHooks.
By composing native hooks, you are creating a custom hook. Native hooks and custom hooks can be composed and nested.
// Define a custom hook
function useCustomHook() {
const [currentState, setState] = useState(0)
useEffect(() => {
if (currentState < 5) {
setState(currentState + 1)
}
}, [currentState])
return currentState
}
// Run the hook
const custom = runHook(useCustomHook)
// Gets called every time the hook has run
// In this example it will get called with the values 0, 1, 2, 3, 4, 5
custom.on('update', (value) => console.log(value))
// Gets called when the hook was destroyed
custom.on('destroy', (error) => console.error('destroyed'))
runHook(fn) returns the following interface, which lets you await the next value, await effects, read the latest value and subscribe to updates to your hook.
export interface Root<Props, HookValue> {
displayName: string
/**
* Resolves once the hooks has rendered.
* Might resolve after being intermediately suspended.
*/
value: Promise<HookValue>
/**
* Resolves once all side effects have run (cleanups, useLayoutEffects and useEffects)
*/
effects: Promise<void>
/**
* Returns the current value of the ran hook (outermost custom `useXYZ` hook)
* This might return undefined or a stole/older value while the hook is suspended.
* Recommended: Use the value promise to get the latest value.
*/
currentValue?: HookValue
/**
* While the hook is suspended, this will return true
*/
isSuspended: boolean
/**
* If the hook was destroyed (by error or externally), this will return true
*/
isDestroyed: boolean
/**
* Resolves after all cleanup functions have run
*/
isDestroyedPromise: Promise<unknown> | undefined
/**
* Re-run the hook with new props
*/
render: RenderFn<Props, HookValue>
/**
* Re-run the hook with (partially) new props.
*/
update: UpdateFn<Props, HookValue>
/**
* Subscribe to hook updates
*/
on: <T extends keyof SubscriptionTypes>(
type: T,
subscription: SubscriptionTypes<HookValue>[T]
) => UnsubscribeFn
/**
* Unsubscribe from hook updates
*/
off: <T extends keyof SubscriptionTypes>(
type: T,
subscription: SubscriptionTypes<HookValue>[T]
) => void
/**
* Destroy the hook.
* This will run all cleanup functions and reject the value promise
*/
destroy(reason?: unknown): Promise<unknown>
}
FAQs
Lorem ipsum
We found that @xiel/outer-hooks 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.

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.