Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
any-hooks
Advanced tools
Readme
Resolve available hooks. Hooks are detected from installed hook libraries, if no hooks found - manual setup is expected.
import { useState, useEffect } from 'any-hooks'
export function useMyHook(init) {
let [state, setState] = useState(init)
}
react
preact
rax
haunted
fuco
augmentor
(dom-augmentor
, neverland
)atomico
tng-hooks
(manual)fn-with-hooks
(manual)plumejs
(manual)component-register-hooks
(manual)import hooks from 'tng-hooks'
import setHooks, { useState, useEffect } from 'any-hooks'
// switch global hooks to custom hooks lib, like tng-hooks
setHooks(hooks)
React | Preact | Rax | Haunted | Augmentor | Fuco | Atomico | TNG-hooks | fn-with-hooks | |
---|---|---|---|---|---|---|---|---|---|
useState | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
useEffect | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
useContext | ✅ | ✅ | ✅ | ✅ | ✅* | ✅ | ❌ | ❌ | ❌ |
useCallback | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
useReducer | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
useMemo | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅* | ✅ | ✅ |
useRef | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
useLayoutEffect | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
useImperativeHandle | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
useDebugValue * | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
useTransition * | ✅* | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
useProperty * | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ |
* − non-standard
Any-hooks can be used in hooks libraries (like unihooks) to extend frameworks support to non-react.
// super-hooks
import { useState, useEffect } from 'any-hooks'
export function useMySuperHook(init) {
let [state, setState] = useState(init)
// ...
return [state, setState]
}
Any-hooks can enable react hooks for non-react libraries, like augmentor, haunted etc. The strategy is similar to preact/compat aliasing.
webpack.config.js
:
const config = {
//...
"resolve": {
"alias": {
"react": "any-hook"
},
},
// mute warnings
"stats": {
"warnings": false
}
}
package.json
:
{
"alias": {
"react": "any-hooks"
},
}
.babelrc
:
{
"plugins": [
["module-resolver", {
"alias": {
"react": "any-hooks"
}
}]
]
}
rollup.config.js
:
import alias from '@rollup/plugin-alias'
module.exports = {
//...
plugins: [
alias({
entries: {
react: 'any-hooks'
}
})
]
}
jest.config.js
:
{
// ...
"moduleNameMapper": {
"react": "any-hooks"
},
}
npm i -D aliasify
, then in package.json
:
{
"aliasify": {
"aliases": {
"react": "any-hooks"
}
},
}
npm i -D module-alias
, then:
var moduleAlias = require('module-alias')
moduleAlias.addAliases({ 'react': 'any-hooks' })
MIT
HK
FAQs
Resolve or switch hooks
The npm package any-hooks receives a total of 14 weekly downloads. As such, any-hooks popularity was classified as not popular.
We found that any-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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.