Skip to content

Commit d4ff426

Browse files
authored
Merge branch 'master' into tests-typecheck
2 parents 26b84e8 + 461b093 commit d4ff426

33 files changed

+924
-823
lines changed

.codesandbox/ci.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"sandboxes": [
3-
"vanilla",
4-
"vanilla-ts"
5-
],
6-
"node": "14"
2+
"sandboxes": ["vanilla", "vanilla-ts"],
3+
"node": "16"
74
}

.github/workflows/test.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
- '.github/**'
1818
- 'src/**'
1919
- 'test/**'
20+
- '.github/**/*.yaml'
21+
- 'tsup.config.ts'
2022
2123
build:
2224
needs: changes
@@ -129,3 +131,74 @@ jobs:
129131
yarn check-types
130132
yarn test:typecheck
131133
yarn test:types
134+
135+
test-published-artifact:
136+
name: Test Published Artifact ${{ matrix.example }}
137+
138+
needs: [build]
139+
runs-on: ubuntu-latest
140+
strategy:
141+
fail-fast: false
142+
matrix:
143+
node: ['16.x']
144+
example:
145+
[
146+
'cra4',
147+
'cra5',
148+
'next',
149+
'vite',
150+
'node-standard',
151+
'node-esm',
152+
'are-the-types-wrong'
153+
]
154+
steps:
155+
- name: Checkout repo
156+
uses: actions/checkout@v2
157+
158+
- name: Use node ${{ matrix.node }}
159+
uses: actions/setup-node@v2
160+
with:
161+
node-version: ${{ matrix.node }}
162+
cache: 'yarn'
163+
164+
- name: Clone RTK repo
165+
run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit
166+
167+
- name: Check folder contents
168+
run: ls -l .
169+
170+
- name: Install deps
171+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
172+
run: yarn install
173+
174+
- uses: actions/download-artifact@v2
175+
with:
176+
name: package
177+
path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
178+
179+
- name: Check folder contents
180+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
181+
run: ls -l .
182+
183+
- name: Install build artifact
184+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
185+
run: yarn add ./package.tgz
186+
187+
- name: Show installed package versions
188+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
189+
run: yarn info redux && yarn why redux
190+
191+
- name: Build example
192+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
193+
run: yarn build
194+
195+
- name: Run test step
196+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
197+
run: yarn test
198+
if: matrix.example != 'are-the-types-wrong'
199+
200+
- name: Run test step
201+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
202+
# Ignore "FalseCJS" errors in the `attw` job
203+
run: yarn test -n FalseCJS
204+
if: matrix.example == 'are-the-types-wrong'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It helps you write applications that behave consistently, run in different envir
88
You can use Redux together with [React](https://reactjs.org), or with any other view library.
99
It is tiny (2kB, including dependencies), and has a rich ecosystem of addons.
1010

11-
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/reduxjs/redux/Tests/master?style=flat-square)
11+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/reduxjs/redux/test.yaml?branch=master&event=push&style=flat-square)
1212
[![npm version](https://img.shields.io/npm/v/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux)
1313
[![npm downloads](https://img.shields.io/npm/dm/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux)
1414
[![redux channel on discord](https://img.shields.io/badge/discord-%23redux%20%40%20reactiflux-61dafb.svg?style=flat-square)](https://discord.gg/0ZcbPKXt5bZ6au5t)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:::caution
2+
3+
Note that **this tutorial intentionally shows older-style Redux logic patterns that require more code than the "modern Redux" patterns with Redux Toolkit we teach as the right approach for building apps with Redux today**, in order to explain the principles and concepts behind Redux. It's _not_ meant to be a production-ready project.
4+
5+
See these pages to learn how to use "modern Redux" with Redux Toolkit:
6+
7+
- [**The full "Redux Essentials" tutorial**](../tutorials/essentials/part-1-overview-concepts.md), which teaches "how to use Redux, the right way" with Redux Toolkit for real-world apps. **We recommend that all Redux learners should read the "Essentials" tutorial!**
8+
- [**Redux Fundamentals, Part 8: Modern Redux with Redux Toolkit**](../tutorials/fundamentals/part-8-modern-redux.md), which shows how to convert the low-level examples from earlier sections into modern Redux Toolkit equivalents
9+
10+
:::

docs/faq/CodeStructure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ axiosInstance.interceptors.request.use(config => {
202202
Then, in your entry point file, inject the store into the API setup file:
203203

204204
```js title="index.js"
205-
import store from "./app/store".
206-
import {injectStore} from "./common/api";
207-
injectStore(store);
205+
import store from './app/store'
206+
import { injectStore } from './common/api'
207+
injectStore(store)
208208
```
209209

210210
This way, the application setup is the only code that has to import the store, and the file dependency graph avoids circular dependencies.

docs/introduction/why-rtk-is-redux-today.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ Whether you're a brand new Redux user setting up your first project, or an exper
1818
simplify an existing application, **[Redux Toolkit](https://redux-toolkit.js.org/)** can help you
1919
make your Redux code better.
2020

21+
:::tip
22+
23+
See these pages to learn how to use "modern Redux" with Redux Toolkit:
24+
25+
- [**The "Redux Essentials" tutorial**](../tutorials/essentials/part-1-overview-concepts.md), which teaches "how to use Redux, the right way" with Redux Toolkit for real-world apps,
26+
- [**Redux Fundamentals, Part 8: Modern Redux with Redux Toolkit**](../tutorials/fundamentals/part-8-modern-redux.md), which shows how to convert the low-level examples from earlier sections of the tutorial into modern Redux Toolkit equivalents
27+
- [**Using Redux: Migrating to Modern Redux**](../usage/migrating-to-modern-redux.mdx), which covers how to migrate different kinds of legacy Redux logic into modern Redux equivalents
28+
29+
:::
30+
2131
## How Redux Toolkit Is Different Than the Redux Core
2232

2333
### What Is "Redux"?
@@ -55,7 +65,7 @@ Other than that, all the other Redux-related logic in your app has to be written
5565

5666
The good news is that this means Redux _can_ be used in many different ways. The bad news is that there are no helpers to make any of your code easier to write.
5767

58-
For example, a reducer function is _just_ a function. Prior to Redux Toolkit, you'd typically write it that reducer with a `switch` statement and manual updates. You'd also probably have hand-written action creators and action type constants along with it:
68+
For example, a reducer function is _just_ a function. Prior to Redux Toolkit, you'd typically write that reducer with a `switch` statement and manual updates. You'd also probably have hand-written action creators and action type constants along with it:
5969

6070
```js title="Legacy hand-written Redux usage"
6171
const ADD_TODO = 'ADD_TODO'
@@ -230,7 +240,7 @@ If you are using the `redux` core package by itself, your code will continue to
230240

231241
See these docs pages and blog posts for more details
232242

233-
- [Redux Essentials: Redux App Structure](../tutorials/essentials/part-2-app-structure.md)
243+
- [Redux Essentials: Redux Toolkit App Structure](../tutorials/essentials/part-2-app-structure.md)
234244
- [Redux Fundamentals: Modern Redux with Redux Toolkit](../tutorials/fundamentals/part-8-modern-redux.md)
235245
- [Redux Style Guide: Best Practices and Recommendations](../style-guide/style-guide.md)
236246
- [Presentation: Modern Redux with Redux Toolkit](https://blog.isquaredsoftware.com/2022/06/presentations-modern-redux-rtk/)

docs/redux-toolkit/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Redux Toolkit includes:
5959
- [`createEntityAdapter`](https://redux-toolkit.js.org/api/createEntityAdapter): generates a set of reusable reducers and selectors to manage normalized data in the store
6060
- 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.
6161

62-
Redux Toolkit also has a new [**RTK Query data fetching API**](https://redux-toolkit.js.org/rtk-query/overview). RTK Query is a powerful data fetching and caching tool built specifically for Redux. It is designed to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself.
62+
Redux Toolkit also has the [**RTK Query data fetching API**](https://redux-toolkit.js.org/rtk-query/overview). RTK Query is a powerful data fetching and caching tool built specifically for Redux. It is designed to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself.
6363

6464
## Documentation
6565

docs/tutorials/essentials/part-1-overview-concepts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ This is a small example of **"one-way data flow"**:
143143

144144
![One-way data flow](/img/tutorials/essentials/one-way-data-flow.png)
145145

146-
However, the simplicity can break down when we have **multiple components that need to share and use the same state**, especially if those components are located in different parts of the application. Sometimes this can be solved by ["lifting state up"](https://reactjs.org/docs/lifting-state-up.html) to parent components, but that doesn't always help.
146+
However, the simplicity can break down when we have **multiple components that need to share and use the same state**, especially if those components are located in different parts of the application. Sometimes this can be solved by ["lifting state up"](https://react.dev/learn/sharing-state-between-components) to parent components, but that doesn't always help.
147147

148148
One way to solve this is to extract the shared state from the components, and put it into a centralized location outside the component tree. With this, our component tree becomes a big "view", and any component can access the state or trigger actions, no matter where they are in the tree!
149149

@@ -459,4 +459,4 @@ Redux does have a number of new terms and concepts to remember. As a reminder, h
459459

460460
## What's Next?
461461

462-
We've seen each of the individual pieces of a Redux app. Next, continue on to [Part 2: Redux App Structure](./part-2-app-structure.md), where we'll look at a full working example to see how the pieces fit together.
462+
We've seen each of the individual pieces of a Redux app. Next, continue on to [Part 2: Redux Toolkit App Structure](./part-2-app-structure.md), where we'll look at a full working example to see how the pieces fit together.

docs/tutorials/essentials/part-2-app-structure.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
id: part-2-app-structure
3-
title: 'Redux Essentials, Part 2: Redux App Structure'
4-
sidebar_label: 'Redux App Structure'
5-
description: 'The official Redux Essentials tutorial: learn the structure of a typical React + Redux app'
3+
title: 'Redux Essentials, Part 2: Redux Toolkit App Structure'
4+
sidebar_label: 'Redux Toolkit App Structure'
5+
description: 'The official Redux Essentials tutorial: learn the structure of a typical React + Redux Toolkit app'
66
---
77

88
import { DetailedExplanation } from '../../components/DetailedExplanation'
99

1010
:::tip What You'll Learn
1111

12-
- The structure of a typical React + Redux app
12+
- The structure of a typical React + Redux Toolkit app
1313
- How to view state changes in the Redux DevTools Extension
1414

1515
:::

docs/tutorials/essentials/part-3-data-flow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { DetailedExplanation } from '../../components/DetailedExplanation'
2323

2424
## Introduction
2525

26-
In [Part 1: Redux Overview and Concepts](./part-1-overview-concepts.md), we looked at how Redux can help us build maintainable apps by giving us a single central place to put global app state. We also talked about core Redux concepts like dispatching action objects, using reducer functions that return new state values, and writing async logic using thunks. In [Part 2: Redux App Structure](./part-2-app-structure.md), we saw how APIs like `configureStore` and `createSlice` from Redux Toolkit and `Provider` and `useSelector` from React-Redux work together to let us write Redux logic and interact with that logic from our React components.
26+
In [Part 1: Redux Overview and Concepts](./part-1-overview-concepts.md), we looked at how Redux can help us build maintainable apps by giving us a single central place to put global app state. We also talked about core Redux concepts like dispatching action objects, using reducer functions that return new state values, and writing async logic using thunks. In [Part 2: Redux Toolkit App Structure](./part-2-app-structure.md), we saw how APIs like `configureStore` and `createSlice` from Redux Toolkit and `Provider` and `useSelector` from React-Redux work together to let us write Redux logic and interact with that logic from our React components.
2727

2828
Now that you have some idea of what these pieces are, it's time to put that knowledge into practice. We're going to build a small social media feed app, which will include a number of features that demonstrate some real-world use cases. This will help you understand how to use Redux in your own applications.
2929

0 commit comments

Comments
 (0)