reducer function(归约/折叠函数;常译“reducer 函数”):在编程中指一种函数,把一组数据(如数组/序列)通过累积的方式“合并”为一个结果;也常指在 Redux/React 等状态管理语境下,用来根据 action 计算并返回新状态的纯函数。(在不同语境下含义略有侧重。)
/rɪˈduːsər ˈfʌŋkʃən/
A reducer function combines values into one result.
归约函数把多个值合并成一个结果。
In Redux, a reducer function takes the current state and an action, then returns a new state without mutating the old one.
在 Redux 中,reducer 函数接收当前状态和一个 action,并在不修改旧状态的情况下返回新状态。
useReducer)与状态管理章节中讨论 reducer function 的用法。 Array.prototype.reduce)相关章节中涉及“归约函数/回调函数”的概念与示例。