New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-undoable

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-undoable - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"name": "react-undoable",
"version": "0.1.1",
"version": "0.1.2",
"description": "Easily undo/redo any state in React, no external dependencies",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1,2 +0,2 @@

# React Undoable
# react-undoable 🔄

@@ -141,4 +141,47 @@ ![npm](https://img.shields.io/npm/v/react-undoable.svg)

## API
react-undoable exposes a small API to use in your child components.
### `<Undoable />`
Initializes the main Undoable component that manages state. Renders a child function that passed
the different state trees and methods to manage state.
#### Props
```typescript
interface IUndoableProps<T> {
initialState: T
children(props: IUndoableState<T> & IUndoableMethods<T>): React.ReactNode
}
```
#### Methods
The Undoable component passes down the following methods in the child function.
##### pushState(state: T): void
Pushes a new state to the stack. This tracks the change so it can be undone or redone.
##### updateState(state: T): void
Update the state but **do not track the change**. This is useful for when you want to update the
state but do not want undo/redo to apply the previous change (e.g. highlighting a selected layer)
##### undo(): void
Undo the current state and replace with the previously tracked state.
##### redo(): void
Redo a previous undone state.
##### resetState(): void
Reset the state stack so there are no undos/redos.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc