
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@dhmk/react
Advanced tools
useRefLive(x: T): Ref<T>Returns a ref which is updated after each render.
useCallbackLive(fn: T): TReturns a function with a stable identity that calls the latest provided fn function passing all args to it.
It's safe to omit the function from the
useEffectoruseCallbackdependency list.
useUpdate(): FunctionLike class component forceUpdate.
useGetter(x: T): () => TReturns a function with a stable identity that returns an argument provided to it.
It's safe to omit the function from the
useEffectoruseCallbackdependency list.
useIsomorphicLayoutEffectuseLayoutEffect without warning if used outside browser.
useState2(initial, postProcess: (newValue, oldValue) => finalValue): [state, setState, getState]Like useState but with mediation process. Also returns state getter function as the third item.
useStateMerge(initial): [state, setState, getState]Like useState but with shallow merging instead of replacing.
useEffect2(fn, deps)Like useEffect but fn is called with two arguments:
isInitial: booleanprevDeps: [] | undefineduseEffectUpdate(fn, deps)Like useEffect but skips first effect invocation.
usePromise(p?: Promise): [PromiseState, setPromise(p?: Promise): Promise]PromiseState = {
isPending: boolean
value: T | undefined
error: E | undefined
}
Tracks promise status.
<Render>{() => ...}</Render>Useful for using hooks inside a class component.
class extends React.Component {
render() {
return <Render>{() => {
const [count, setCount] = React.usecount(1)
this.setCount = setCount // interop with class
return <p>{count}</p>
}}</Render>
}
}
effect(reactClassInstance, effectFn, getDeps?): DisposeRegisters and runs an effect. All effects are automatically disposed on unmount.
getDeps is a function that returns an array of dependencies, similar to React.useEffect.
class extends React.Component {
componentDidMount() {
effect(
this,
() => {
// I will run instantly and then in `componentDidUpdate` if my deps changed
return () => {
// optional dispose here
}
},
() => [this.props.someValue, this.props.otherValue])
}
}
FAQs
Various React.js hooks and components
The npm package @dhmk/react receives a total of 22 weekly downloads. As such, @dhmk/react popularity was classified as not popular.
We found that @dhmk/react 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.