
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.
English | 简体中文
React state manager based on hooks. Inspired by umijs/hox.
Hox is a great hooks-based state management tool, but it has several problems:
yarn add hookso
# or
npm install hookso
// counter.ts
import { useState } from 'react';
import { create } from 'hookso';
export const counter = create(() => {
const [count, setCount] = useState(0);
const decrement = () => setCount(count - 1);
const increment = () => setCount(count + 1);
return { count, decrement, increment };
});
// App.tsx
import React from 'react';
import { counter } from './counter';
export default () => {
const { count, decrement, increment } = counter.use();
return (
<>
count is: {count}
<button onClick={decrement}>-</button>
<button onClick={increment}>+</button>
</>
);
};
Then mount counter.Provider to the appropriate ancestor node.
// index.tsx
import React from 'react';
import { render } from 'react-dom';
import { counter } from './counter';
import App from './App';
const rootElement = document.getElementById('root');
render(
<counter.Provider>
<App />
</counter.Provider>,
rootElement
);
So far, only one API create is used to complete the state management of the counter.
// App.tsx
import React from 'react';
import { counter } from './counter';
export interface AppProps {
count: number;
decrement: () => void;
increment: () => void;
}
class App extends React.Component<AppProps> {
render() {
const { count, decrement, increment } = this.props;
return (
<>
count is: {count}
<button onClick={decrement}>-</button>
<button onClick={increment}>+</button>
</>
);
}
}
// connect
export default counter.connect()(App);
import React from 'react';
import { Provider } from 'hookso';
import { user } from './user';
import { counter } from './counter';
import App from './App';
export default () => (
<Provider stores={[user, counter]}>
<App />
</Provider>
);
The use returned by the create method supports passing in a depsFn function, and each time the hooks state value changes, depsFn will be called first, and then the returned dependency array will be compared with the previous one. If it is inconsistent, it will Trigger a component status update, which is similar to the second parameter of useMemo and useEffect.
const { count } = counter.use(state => [state.x, state.y]);
Here, when using use, a depsFn is passed in. The effect achieved is that the component state update will be triggered when state.x or state.y changes.
FAQs
React state manager based on hooks
We found that hookso 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.