Skip to content

Commit 762cf67

Browse files
authored
Add RTK Overview page (#3622)
* Update Docusaurus * Add RTK overview page * Clean up Getting Started examples list
1 parent b036fec commit 762cf67

File tree

5 files changed

+6010
-4308
lines changed

5 files changed

+6010
-4308
lines changed

docs/introduction/GettingStarted.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ You can use Redux together with [React](https://reactjs.org), or with any other
1818
Redux is available as a package on NPM for use with a module bundler or in a Node application:
1919

2020
```bash
21+
# NPM
2122
npm install --save redux
23+
24+
# Yarn
25+
yarn add redux
2226
```
2327

2428
It is also available as a precompiled UMD package that defines a `window.Redux` global variable. The UMD package can be used as a [`<script>` tag](https://unpkg.com/redux/dist/redux.js) directly.
@@ -27,11 +31,11 @@ For more details, see the [Installation](Installation.md) page.
2731

2832
## Redux Toolkit
2933

30-
Redux itself is small and unopinionated. We also have a separate package called **[Redux Toolkit](https://redux-toolkit.js.org/)**,
34+
Redux itself is small and unopinionated. We also have a separate addon package called **[Redux Toolkit](https://redux-toolkit.js.org/)**,
3135
which includes some opinionated defaults that help you use Redux more effectively. It's our official recommended approach
3236
for writing Redux logic.
3337

34-
RTK includes utilities that help simplify a lot of common use cases, including [store setup](https://redux-toolkit.js.org/api/configureStore),
38+
RTK includes utilities that help simplify many common use cases, including [store setup](https://redux-toolkit.js.org/api/configureStore),
3539
[creating reducers and writing immutable update logic](https://redux-toolkit.js.org/api/createreducer),
3640
and even [creating entire "slices" of state at once](https://redux-toolkit-kit.js.org/api/createslice).
3741

@@ -99,20 +103,11 @@ In a typical Redux app, there is just a single store with a single root reducing
99103

100104
This architecture might seem like an overkill for a counter app, but the beauty of this pattern is how well it scales to large and complex apps. It also enables very powerful developer tools, because it is possible to trace every mutation to the action that caused it. You can record user sessions and reproduce them just by replaying every action.
101105

102-
## Examples
106+
## Example Projects
103107

104108
The Redux repository contains several example projects demonstrating various aspects of how to use Redux. Almost all examples have a corresponding CodeSandbox sandbox. This is an interactive version of the code that you can play with online.
105109

106-
- [**Counter Vanilla**](/introduction/examples#counter-vanilla): [Source](https://github.com/reduxjs/redux/tree/master/examples/counter-vanilla)
107-
- [**Counter**](/introduction/examples#counter): [Source](https://github.com/reduxjs/redux/tree/master/examples/counter) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/counter)
108-
- [**Todos**](/introduction/examples#todos): [Source](https://github.com/reduxjs/redux/tree/master/examples/todos) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos)
109-
- [**Todos with Undo**](/introduction/examples#todos-with-undo): [Source](https://github.com/reduxjs/redux/tree/master/examples/todos-with-undo) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos-with-undo)
110-
- [**TodoMVC**](/introduction/examples#todomvc): [Source](https://github.com/reduxjs/redux/tree/master/examples/todomvc) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todomvc)
111-
- [**Shopping Cart**](/introduction/examples#shopping-cart): [Source](https://github.com/reduxjs/redux/tree/master/examples/shopping-cart) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/shopping-cart)
112-
- [**Tree View**](/introduction/examples#tree-view): [Source](https://github.com/reduxjs/redux/tree/master/examples/tree-view) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/tree-view)
113-
- [**Async**](/introduction/examples#async): [Source](https://github.com/reduxjs/redux/tree/master/examples/async) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/async)
114-
- [**Universal**](/introduction/examples#universal): [Source](https://github.com/reduxjs/redux/tree/master/examples/universal)
115-
- [**Real World**](/introduction/examples#real-world): [Source](https://github.com/reduxjs/redux/tree/master/examples/real-world) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/real-world)
110+
See the complete list of examples in the **[Examples page](./Examples.md)**.
116111

117112
## Learn Redux
118113

@@ -168,8 +163,6 @@ Here are some suggestions on when it makes sense to use Redux:
168163
- You need a single source of truth for your state
169164
- You find that keeping all your state in a top-level component is no longer sufficient
170165

171-
Yes, these guidelines are subjective and vague, but this is for good reason. The point at which you should integrate Redux into your application is different for every user and different for every application.
172-
173166
> **For more thoughts on how Redux is meant to be used, see:**<br>
174167
>
175168
> - **[Redux FAQ: When should I use Redux?](../faq/General.md#when-should-i-use-redux)**

docs/redux-toolkit/overview.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
id: overview
3+
title: Redux Toolkit: Overview
4+
sidebar_label: Redux Toolkit: Overview
5+
hide_title: true
6+
---
7+
8+
## What is Redux Toolkit?
9+
10+
**[Redux Toolkit](https://redux-toolkit.js.org)** is our official, opinionated, batteries-included toolset for efficient Redux development. It is intended to be the standard way to write Redux logic, and we strongly recommend that you use it.
11+
12+
It includes several utility functions that simplify the most common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once without writing any action creators or action types by hand. It also includes the most widely used Redux addons, like Redux Thunk for async logic and Reselect for writing selector functions, so that you can use them right away.
13+
14+
### Installation
15+
16+
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
17+
18+
```bash
19+
# NPM
20+
npm install --save @reduxjs/toolkit
21+
22+
# Yarn
23+
yarn add @reduxjs/toolkit
24+
```
25+
26+
## Purpose
27+
28+
The Redux core library is deliberately unopinionated. It lets you decide how you want to handle everything, like store setup, what your state contains, and how you want to build your reducers.
29+
30+
This is good in some cases, because it gives you flexibility, but that flexibility isn't always needed. Sometimes we just want the simplest possible way to get started, with some good default behavior out of the box. Or, maybe you're writing a larger application and finding yourself writing some similar code, and you'd like to cut down on how much of that code you have to write by hand.
31+
32+
**Redux Toolkit** was originally created to help address three common concerns about Redux:
33+
34+
- "Configuring a Redux store is too complicated"
35+
- "I have to add a lot of packages to get Redux to do anything useful"
36+
- "Redux requires too much boilerplate code"
37+
38+
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://dev-blog.apollodata.com/zero-config-graphql-state-management-27b1f1b3c2c3), we can provide an official recommended set of tools that handle the most common use cases and reduce the need to make extra decisions.
39+
40+
## Why You Should Use Redux Toolkit
41+
42+
**Redux Toolkit** makes it easier to write good Redux applications and speeds up development, by baking in our recommended best practices, providing good default behaviors, catching mistakes, and allowing you to write simpler code. Redux Toolkit is **beneficial to all Redux users** regardless of skill level or experience. It can be added at the start of a new project, or used as part of an incremental migration in an existing project.
43+
44+
Note that **you are not _required_ to use Redux Toolkit to use Redux**. There are many existing applications that use other Redux wrapper libraries, or write all Redux logic "by hand". **If you prefer to use a different approach, go ahead!**
45+
46+
Overall, whether you're a brand new Redux user setting up your first project, or an experienced user who wants to simplify an existing application, **using Redux Toolkit will make your code better and more maintainable**.
47+
48+
## What's Included
49+
50+
Redux Toolkit includes:
51+
52+
- A [`configureStore()` function](https://redux-toolkit.js.org/api/configureStore) with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.
53+
- A [`createReducer()` utility](https://redux-toolkit.js.org/api/createReducer) that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the [`immer` library](https://github.com/mweststrate/immer) to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
54+
- A [`createAction()` utility](https://redux-toolkit.js.org/api/createAction) that returns an action creator function for the given action type string. The function itself has `toString()` defined, so that it can be used in place of the type constant.
55+
- A [`createSlice()` function](https://redux-toolkit.js.org/api/createSlice) that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates a slice reducer with corresponding action creators and action types.
56+
- The [`createSelector` utility](https://redux-toolkit.js.org/api/createSelector) from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use.
57+
58+
## Documentation
59+
60+
The complete Redux Toolkit documentation is available at **[https://redux-toolkit.js.org](https://redux-toolkit.js.org)**.
61+
62+
### Documentation Links
63+
64+
- **Introduction**
65+
- [Quick Start](https://redux-toolkit.js.org/introduction/quick-start)
66+
- **Tutorials**
67+
- [Basic Tutorial](https://redux-toolkit.js.org/tutorials/basic-tutorial)
68+
- [Intermediate Tutorial](https://redux-toolkit.js.org/tutorials/intermediate-tutorial)
69+
- [Advanced Tutorial](https://redux-toolkit.js.org/tutorials/advanced-tutorial)
70+
- **Using Redux Toolkit**
71+
- [Usage Guide](https://redux-toolkit.js.org/usage/usage-guide)
72+
- **API Reference**
73+
- [`configureStore`](https://redux-toolkit.js.org/api/configureStore)
74+
- [`getDefaultMiddleware`](https://redux-toolkit.js.org/api/getDefaultMiddleware)
75+
- [`createReducer`](https://redux-toolkit.js.org/api/createReducer)
76+
- [`createAction`](https://redux-toolkit.js.org/api/createAction)
77+
- [`createSlice`](https://redux-toolkit.js.org/api/createSlice)
78+
- [`createSelector`](https://redux-toolkit.js.org/api/createSelector)
79+
- [Other Exports](https://redux-toolkit.js.org/api/other-exports)

0 commit comments

Comments
 (0)