
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-use-slice
Advanced tools
A react hook to use reducers with an API like createSlice from Redux toolkit, in a typesafe way, with performance in mind.
A react hook to use reducers with an API like createSlice from Redux toolkit, in a typesafe way, with performance in mind.
npm install react-use-slice
import { createContext } from 'react';
import useSlice from 'react-use-slice';
const initialState = {
score: 0
};
const scoreSlice = {
name: 'score', // "name" is optional. It is used in dev tools
initialState,
reducers: {
increment(state, payload) {
const score = state.score + 1;
return { ...state, score };
},
decrement(state, payload) {
const score = state.score - 1;
return { ...state, score };
}
}
};
export const ScoreContext = createContext(null);
export const ScoreProvider = ({ children }) => {
// Actions will be automaticaly dispatched
const [state, actions] = useSlice(scoreSlice);
return (
<ScoreContext.Provider value={{ ...state, ...actions }}>
{children}
</ScoreContext.Provider>
);
};
import { createContext } from 'react';
import useSlice, { createSlice, CombineStateAndActions } from 'react-use-slice';
const initialState = {
score: 0
};
const scoreSlice = createSlice({
name: 'score', // "name" is optional. It is used in dev tools
initialState,
reducers: {
increment(state, payload: number) {
const score = state.score + 1;
return { ...state, score };
},
decrement(state, payload: number) {
const score = state.score - 1;
return { ...state, score };
}
}
});
export const ScoreContext =
createContext<CombineStateAndActions<typeof scoreSlice> | null>(null);
export const ScoreProvider = ({ children }) => {
// Actions will be automaticaly dispatched
const [state, actions] = useSlice(scoreSlice);
return (
<ScoreContext.Provider value={{ ...state, ...actions }}>
{children}
</ScoreContext.Provider>
);
};
FAQs
A react hook to use reducers with an API like createSlice from Redux toolkit, in a typesafe way, with performance in mind.
We found that react-use-slice 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.