
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
react-undo-redo-state
Advanced tools
Effortlessly enable undo and redo capabilities in your React applications with this powerful custom hook. 'useUndoRedoState' empowers users with intuitive keyboard shortcuts and programmatic control, allowing them to revert or reapply state changes seamle
useUndoRedoState is a custom React hook that provides undo and redo functionality for state management. It allows you to easily integrate undo and redo capabilities into your React applications, giving users the ability to revert or reapply state changes with keyboard shortcuts or programmatic methods.
Cmd+Z for undo and Cmd+Shift+Z for redo on macOS, or Ctrl+Z and Ctrl+Shift+Z on other platforms).undo and redo functions.You can install the package via npm or yarn:
npm install react-undo-redo-state
yarn add react-undo-redo-state
import React from 'react';
import useUndoRedoState from 'react-undo-redo-state';
export default function CounterApp() {
const [
count,
setCount,
undo,
redo,
resetState,
clearHistory
] = useUndoRedoState(0);
return (
<div className="w-full h-screen mt-20">
<div className="flex flex-col gap-5 items-center">
<p className="text-2xl">{count}</p>
<div className="flex items-center gap-5">
<button onClick={() => setCount(count - 1)}>Decrement</button>
<button onClick={() => setCount(count + 1)}>Increment</button>
<button onClick={undo}>Undo</button>
<button onClick={redo}>Redo</button>
<button onClick={resetState}>Reset</button>
<button onClick={clearHistory}>Clear History</button>
</div>
</div>
</div>
);
}
The useUndoRedoState hook accepts two arguments:
initialState: The initial state value.options (optional): An object containing configuration options:maxStackSize: The maximum size of the undo and redo stacks (default: 10).onUndo: A callback function to be called after an undo operation.onRedo: A callback function to be called after a redo operation.The hook returns an array with six elements:
state: The current state value.setValue: A function to set a new state value. This function automatically adds the previous state to the undo stack, enabling undo operations.undo: A function to revert the state to the previous value in the undo stack.redo: A function to apply the next value from the redo stack to the state.resetState: A function to reset the state to the initial value.clearHistory: A function to clear both the undo and redo stacks.Check out the useUndoRedoState hook demo here featuring a simple Next.js counter app.
Contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository
This project is licensed under the MIT License.
resetState and clearHistory functions.setValue function.FAQs
Effortlessly enable undo and redo capabilities in your React applications with this powerful custom hook. 'useUndoRedoState' empowers users with intuitive keyboard shortcuts and programmatic control, allowing them to revert or reapply state changes seamle
The npm package react-undo-redo-state receives a total of 18 weekly downloads. As such, react-undo-redo-state popularity was classified as not popular.
We found that react-undo-redo-state 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.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.