Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Redux Slice | Redux in Practice
Introduction to Redux
course content

Зміст курсу

Introduction to Redux

Introduction to Redux

1. Getting Started
2. Fundamental Concepts
3. Redux in Practice
4. Creating a React-Redux Application

bookRedux Slice

A slice is a collection of reducer and action logic for a single feature of an application, often arranged in a single file. For example, all the reducer logic related to the counter is in counterSlice.

A slice may also refer to a part of the application state for a specific feature, hence the name slice. A Redux state can be divided into multiple slices. In a chat application, the Redux Store might look like this:

Here posts, comments, and reactions are separate slices of the Redux state, handled by the slice reducers postReducer, commentsReducer, and reactionsReducer, respectively.

A Slice Reducer is a reducer associated with a specific slice. For example, postReducer is called a slice reducer for postSlice. It can also be referred to as a 'reducer' in more general terminology.

A slice in a Redux store creates a portion of a state defined by the assigned key name, which is managed by a specific reducer (slice reducer). In the previous chapter, you were given the task of creating a slice using the reducer from todosSlice:

The overall state of this application might roughly look like this:

Since the above application has only one slice, it has only one section called todos. We can create more slices:

The state might look something like this:

Since we have not looked at what's inside the todosSlice file, we cannot tell what data will be in there initially. In the next chapter, it will become clearer.

Why should you use slice in a Redux application?

Why should you use slice in a Redux application?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 4
We're sorry to hear that something went wrong. What happened?
some-alt