-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
自己写一个 redux #7386
自己写一个 redux #7386
Conversation
校对认领 @fanyijihua @lsvih |
@nia3y 好的! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tanglie1993 @lsvih 校对完成
希望译者注意下格式问题wiki 百科
article/2020/how-to-build-redux.md
Outdated
|
||
Note that technically we'll be building [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **and** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier). At Zapier, we pair Redux with the (awesome) UI library [React](https://facebook.github.io/react/), and that's the pairing that shows up most in the wild. But even if you use Redux with something else, most everything here will still apply. | ||
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。 | |
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他库相组合,这里讲解的大部分内容仍然适用。 |
article/2020/how-to-build-redux.md
Outdated
|
||
Most useful apps will get their state from a server, but let's start by creating our state locally. Even if we are retrieving from the server, we have to seed the app with something anyway. Our app will be a simple note-taking app. This is mostly to avoid making yet another todo app, but it will also force us to make an interesting state decision later. | ||
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
【也要用一些东西把应用先初始化的】=>【也要先用一些状态初始化应用】
【这主要是为了防止写一个新的清单应用】=>【这主要是为了防止写另一个清单应用】
article/2020/how-to-build-redux.md
Outdated
如果中间件决定要发出一个新的 action,这个 action 将会通过中间件传递下去。 | ||
我们需要创建这个函数,因为我们即将修改 store 的 `dispatch` 方法。 | ||
这是另一个修改对象的例子,它可以简化问题。Redux 可以破坏规则,只要它能够帮助开发者遵循规则。:-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注:这三个是一段的,希望修改一下
article/2020/how-to-build-redux.md
Outdated
@@ -1121,9 +1121,9 @@ store.dispatch = middleware({ | |||
})(coreDispatch); | |||
``` | |||
|
|||
That calls the middleware, passing it an object that has access to our re-dispatch function as well as our `getState` function. The middleware should return a new function that accepts the ability to call the next dispatch function, which in this case is just the original dispatch function. If your head is spinning a little, don't worry, creating and using middleware is actually pretty easy. | |||
这调用了中间件,传给它一个能访问 "重新dispatch" 函数和 `getState` 函数的对象。这个中间件应该返回一个新的函数,它接收调用下一个 dispatch 函数的函数(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这调用了中间件,传给它一个能访问 "重新dispatch" 函数和 `getState` 函数的对象。这个中间件应该返回一个新的函数,它接收调用下一个 dispatch 函数的函数(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。 | |
这调用了中间件,传给它一个能进行“re-dispatch ”的函数和 `getState` 的函数。这个中间件应该返回一个新的函数,拥有用来接收调用下一个 dispatch 函数的能力(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。 |
@lsvih 校对认领 |
@rachelcdev 好的! |
@lsvih 校对认领 |
@JohnieXu 好的~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通篇校对下来,发现整篇文章就是用翻译工具翻译的,这会给校对者增加非常多的工作量。建议下:即使采用翻译工具翻译的,也最好翻译者自己仔细阅读一下译文。
article/2020/how-to-build-redux.md
Outdated
|
||
Note that technically we'll be building [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **and** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier). At Zapier, we pair Redux with the (awesome) UI library [React](https://facebook.github.io/react/), and that's the pairing that shows up most in the wild. But even if you use Redux with something else, most everything here will still apply. | ||
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。 | |
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **和** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。 |
article/2020/how-to-build-redux.md
Outdated
|
||
Most useful apps will get their state from a server, but let's start by creating our state locally. Even if we are retrieving from the server, we have to seed the app with something anyway. Our app will be a simple note-taking app. This is mostly to avoid making yet another todo app, but it will also force us to make an interesting state decision later. | ||
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定。 | |
虽然大多数真实项目都需要从服务端获取数据作为应用状态,但我们还是先从本地创建状态开始。即使是从服务端获取,也要需要先用本地数据初始化应用的状态对象。为了不再重复写一个待办清单应用,我们将创建一个简单的笔记应用,同时它也可以迫使我们做一个有趣的关于状态的决定。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议这里稍微意译处理一下,这样更通顺
article/2020/how-to-build-redux.md
Outdated
|
||
## Why Redux? | ||
## 为什么是 Redux? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## 为什么是 Redux? | |
## 为何使用 Redux? |
article/2020/how-to-build-redux.md
Outdated
|
||
Before we dig any deeper, let's see what it's like to build our app without Redux. Let's just go ahead and attach our `initialState` object to `window` like this: | ||
在我们继续深入之前,首先来看看不使用 Redux 开发我们的应用是什么样。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在我们继续深入之前,首先来看看不使用 Redux 开发我们的应用是什么样。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样: | |
在我们继续深入之前,首先来看看不使用 Redux 要怎样开发我们创建的应用。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样: |
article/2020/how-to-build-redux.md
Outdated
|
||
```js | ||
window.state = initialState; | ||
``` | ||
|
||
Boom, there's our store! We don't need no stinking Redux. Let's make a component that adds new notes. | ||
嘣,这就是我们的 store!我们不需要什么 Redux。来做一个添加新笔记的组件吧。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘣,这就是我们的 store!我们不需要什么 Redux。来做一个添加新笔记的组件吧。 | |
这就是我们的状态对象(store),我们不需要什么 Redux,下面来添加一个新的笔记组件吧。 |
@lsvih @tanglie1993 校对完成,希望能修改一下 |
@lsvih 修改完毕。 |
@tanglie1993 啊这篇文章中间还有几十个校对意见没有修改或者回应呢= =您是不是漏了 |
Co-authored-by: niayyy <[email protected]> Co-authored-by: JohnieXu <[email protected]>
Co-authored-by: niayyy <[email protected]> Co-authored-by: JohnieXu <[email protected]>
Co-authored-by: niayyy <[email protected]> Co-authored-by: JohnieXu <[email protected]>
Co-authored-by: niayyy <[email protected]> Co-authored-by: JohnieXu <[email protected]>
译文翻译完成,resolve #7279