From 173ff78a5dc698172bdbbbf1b5f78570c13b6af7 Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Fri, 24 Nov 2023 19:59:10 -0500 Subject: [PATCH] Kill the term "reducing function" --- docs/api/Store.md | 4 ++-- docs/api/combineReducers.md | 4 ++-- docs/api/createStore.md | 2 +- docs/introduction/GettingStarted.md | 2 +- docs/understanding/thinking-in-redux/Glossary.md | 2 +- docs/usage/ReducingBoilerplate.md | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/api/Store.md b/docs/api/Store.md index 37fcd1e38c..0554dc2be9 100644 --- a/docs/api/Store.md +++ b/docs/api/Store.md @@ -11,7 +11,7 @@ The only way to change the state inside it is to dispatch an [action](../underst A store is not a class. It's just an object with a few methods on it. -To create a store, pass your root [reducing function](../understanding/thinking-in-redux/Glossary.md#reducer) to Redux Toolkit's [`configureStore` method](https://redux-toolkit.js.org/api/configureStore), which will set up a Redux store with a good default configuration. (Alternately, if you're not yet using Redux Toolkit, you can use the original [`createStore`](createStore.md) method, but we encourage you to [migrate your code to use Redux Toolkit](../usage/migrating-to-modern-redux.mdx) as soon as possible) +To create a store, **pass your root [reducer function](../understanding/thinking-in-redux/Glossary.md#reducer) to Redux Toolkit's [`configureStore` method](https://redux-toolkit.js.org/api/configureStore)**, which will set up a Redux store with a good default configuration. (Alternately, if you're not yet using Redux Toolkit, you can use the original [`createStore`](createStore.md) method, but we encourage you to [migrate your code to use Redux Toolkit](../usage/migrating-to-modern-redux.mdx) as soon as possible) ## Store Methods @@ -32,7 +32,7 @@ _(any)_: The current state tree of your application. Dispatches an action. This is the only way to trigger a state change. -The store's reducing function will be called with the current [`getState()`](#getState) result and the given `action` synchronously. Its return value will be considered the next state. It will be returned from [`getState()`](#getState) from now on, and the change listeners will immediately be notified. +The store's reducer function will be called with the current [`getState()`](#getState) result and the given `action` synchronously. Its return value will be considered the next state. It will be returned from [`getState()`](#getState) from now on, and the change listeners will immediately be notified. :::caution diff --git a/docs/api/combineReducers.md b/docs/api/combineReducers.md index c2a432cdc3..88130d34c0 100644 --- a/docs/api/combineReducers.md +++ b/docs/api/combineReducers.md @@ -55,7 +55,7 @@ You can control state key names by using different keys for the reducers in the ## Arguments -1. `reducers` (_Object_): An object whose values correspond to different reducing functions that need to be combined into one. +1. `reducers` (_Object_): An object whose values correspond to different reducer functions that need to be combined into one. ```ts combineReducers({ @@ -153,6 +153,6 @@ console.log(store.getState()) ## Tips -- This helper is just a convenience! You can write your own `combineReducers` that [works differently](https://github.com/redux-utilities/reduce-reducers), or even assemble the state object from the child reducers manually and write a root reducing function explicitly, like you would write any other function. +- This helper is just a convenience! You can write your own `combineReducers` that [works differently](https://github.com/redux-utilities/reduce-reducers), or even assemble the state object from the child reducers manually and write a root reducer function explicitly, like you would write any other function. - You may call `combineReducers` at any level of the reducer hierarchy. It doesn't have to happen at the top. In fact you may use it again to split the child reducers that get too complicated into independent grandchildren, and so on. diff --git a/docs/api/createStore.md b/docs/api/createStore.md index 741ad668d4..24009cb651 100644 --- a/docs/api/createStore.md +++ b/docs/api/createStore.md @@ -28,7 +28,7 @@ See the [**Migrating to Modern Redux** page](../usage/migrating-to-modern-redux. ## Arguments -1. `reducer` _(Function)_: A [reducing function](../understanding/thinking-in-redux/Glossary.md#reducer) that returns the next [state tree](../understanding/thinking-in-redux/Glossary.md#state), given the current state tree and an [action](../understanding/thinking-in-redux/Glossary.md#action) to handle. +1. `reducer` _(Function)_: A root [reducer function](../understanding/thinking-in-redux/Glossary.md#reducer) that returns the next [state tree](../understanding/thinking-in-redux/Glossary.md#state), given the current state tree and an [action](../understanding/thinking-in-redux/Glossary.md#action) to handle. 2. [`preloadedState`] _(any)_: The initial state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session. If you produced `reducer` with [`combineReducers`](combineReducers.md), this must be a plain object with the same shape as the keys passed to it. Otherwise, you are free to pass anything that your `reducer` can understand. diff --git a/docs/introduction/GettingStarted.md b/docs/introduction/GettingStarted.md index f3aaead5eb..f28a5f212d 100644 --- a/docs/introduction/GettingStarted.md +++ b/docs/introduction/GettingStarted.md @@ -123,7 +123,7 @@ store.dispatch(decremented()) Instead of mutating the state directly, you specify the mutations you want to happen with plain objects called _actions_. Then you write a special function called a _reducer_ to decide how every action transforms the entire application's state. -In a typical Redux app, there is just a single store with a single root reducing function. As your app grows, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components. +In a typical Redux app, there is just a single store with a single root reducer function. As your app grows, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components. This architecture might seem like a lot 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. diff --git a/docs/understanding/thinking-in-redux/Glossary.md b/docs/understanding/thinking-in-redux/Glossary.md index 4520547cf1..72445e9cde 100644 --- a/docs/understanding/thinking-in-redux/Glossary.md +++ b/docs/understanding/thinking-in-redux/Glossary.md @@ -37,7 +37,7 @@ See also [async action](#async-action) below. type Reducer = (state: S, action: A) => S ``` -A _reducer_ (also called a _reducing function_) is a function that accepts an accumulation and a value and returns a new accumulation. They are used to reduce a collection of values down to a single value. +A _reducer_ is a function that accepts an accumulation and a value and returns a new accumulation. They are used to reduce a collection of values down to a single value. Reducers are not unique to Redux—they are a fundamental concept in functional programming. Even most non-functional languages, like JavaScript, have a built-in API for reducing. In JavaScript, it's [`Array.prototype.reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce). diff --git a/docs/usage/ReducingBoilerplate.md b/docs/usage/ReducingBoilerplate.md index 7b8c0cb96b..f8fca36cff 100644 --- a/docs/usage/ReducingBoilerplate.md +++ b/docs/usage/ReducingBoilerplate.md @@ -484,7 +484,7 @@ AppDispatcher.register(function (action) { export default TodoStore ``` -With Redux, the same update logic can be described as a reducing function: +With Redux, the same update logic can be described as a reducer function: ```js export function todos(state = [], action) {