Integration of React Components with Redux Store

This guide demonstrates how to integrate Syncfusion® React components with a global state managed by Redux Store.

What is Redux store?

Redux Store is the centralized place that holds the entire state of the app. It provides methods to access, update, and subscribe to changes in the state. Redux centralizes state management, making it easier to debug and maintain complex applications.

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

A Redux slice combines the state, actions, and reducer logic for a single feature into one file, making it easier to organize and maintain related state in your React application. 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:

Integrating 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.

Adding 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 store

The value of the Syncfusion® TextBox component is now managed by the Redux store . Whenever you type in the TextBox, the value is updated in the Redux store, and any component connected to the store will receive the updated value automatically. This approach provides a single source of truth for your application's state and makes it easy to manage and share the TextBox value across different parts of your application.

Run the project

Execute the following command to run the project:

The output will appear as follows:

Redux Store

Redux Value: Syncfusion