🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-undo-redo

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

react-undo-redo

A library to add undo-redo to any reducer

2.0.0
Source
npm
Version published
Maintainers
1
Created
Source

react-undo-redo

A utility to add undo and redo functionality to any state managed through a reducer. This library does not require redux. If you're looking for something that adds undo and redo to a state that is managed through redux you might be in the wrong place.

Installation

Through yarn.

yarn add react-undo-redo

Through npm

npm install --save react-undo-redo

Usage

import React from "react";
import { createUndoRedo } from "react-undo-redo";

import { yourReducer } from "./yourReducer";

const { UndoRedoProvider, usePresent, useUndoRedo } = createUndoRedo(
  yourReducer,
  initialState
);

function Application() {
  return <UndoRedoProvider>{/* Your application code */}</UndoRedoProvider>;
}

function Menu() {
  const [undo, redo] = useUndoRedo();

  return (
    <>
      <button onClick={() => undo()}>Undo</button>
      <button onClick={() => redo()}>Redo</button>
    </>
  );
}

FAQs

Package last updated on 09 Oct 2020

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