Integration of React Components with Redux Undo

This guide demonstrates how to integrate Syncfusion® React components with a Redux Undo.

What is Redux Undo?

Redux Undo is a higher-order reducer for Redux, designed to add undo/redo functionality to your application's state management. It works by wrapping your existing reducer and managing a history of past, present, and future states allowing users to undo or redo changes to the application state with ease.

Set up the React project

1. Create a new React project using Vite.

2. Install the necessary Redux dependencies by running the following command:

Configure the Redux slice

Setting up a Redux slice means creating a specific section of your application’s state, along with the actions and reducers that can modify this state.

By wrapping your Redux slice reducer with the undoable function from redux-undo, you can add built-in undo and redo capabilities to your state. Create a new file named textboxSlice.tsx and add the following code snippet.

Set Up the Redux store

After creating the Redux slice, you need to set up the Redux store to combine your reducers and manage your application's state.

Create a new file named store.tsx and add the following code:

Integrate the Redux store with React

To make the Redux store available throughout your React application, you need to wrap your main App component with the Provider from react-redux in main.tsx file. This allows any nested component to access the Redux store state and dispatch actions.

Add Syncfusion® React components

To add Syncfusion® React Textbox component to your application, follow these steps:

1. Install the required Syncfusion® packages

2. Import the required CSS files for the TextBox component into the src/App.css file.

3. Add the TextBox component to the application

Connect the TextBox component to Redux Undo

This section shows how to connect the TextBox component to your Redux store with undo and redo support. When you connect the TextBox component to your Redux store using redux-undo, the values entered in the TextBox can be easily undone and redone.

Run the project

Execute the following command to run the project:

The output will appear as follows: