🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

use-simple-undo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-simple-undo

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Use Events

npm npm npm bundle size (minified + gzip) NpmLicense

Use Simple Undo - Simple solution to handle undo\redo turned into React Hooks. Read about Hooks feature.

Documentation

https://sandiiarov.github.io/use-simple-undo

Install

Note: React 16.8+ is required for Hooks.

With npm

npm i use-simple-undo

Or with yarn

yarn add use-simple-undo

Usage

import useSimpleUndo from 'use-simple-undo';
const Counter = () => {
  const [state, cursor, setValue, { undo, redo }] = useSimpleUndo(0);

  const value = state[cursor];

  const increment = () => setValue(value + 1);
  const decrement = () => setValue(value - 1);

  return (
    <>
      <div>{value}</div>
      <button onClick={increment}>increment</button>
      <button onClick={decrement}>decrement</button>
      <button onClick={undo}>undo</button>
      <button onClick={redo}>redo</button>
    </>
  );
};

FAQs

Package last updated on 14 Feb 2019

Did you know?

Socket

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.

Install

Related posts