You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* rename createStore param `initialState` to `preloadedState`
* rename configureStore param `initialState` to `preloadedState`
* rename `window.__INITIAL_STATE__` in examples and docs
rename window.__INITIAL_STATE__ to window.__PRELOADED_STATE__
Copy file name to clipboardExpand all lines: docs/Glossary.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,10 +114,10 @@ See the complete [store API reference](api/Store.md#dispatch) for more details.
114
114
## Store creator
115
115
116
116
```js
117
-
type StoreCreator= (reducer:Reducer, initialState:?State) => Store
117
+
type StoreCreator= (reducer:Reducer, preloadedState:?State) => Store
118
118
```
119
119
120
-
A store creator is a function that creates a Redux store. Like with dispatching function, we must distinguish the base store creator, [`createStore(reducer, initialState)`](api/createStore.md) exported from the Redux package, from store creators that are returned from the store enhancers.
120
+
A store creator is a function that creates a Redux store. Like with dispatching function, we must distinguish the base store creator, [`createStore(reducer, preloadedState)`](api/createStore.md) exported from the Redux package, from store creators that are returned from the store enhancers.
Creates a Redux [store](Store.md) that holds the complete state tree of your app.
4
4
There should only be a single store in your app.
@@ -7,7 +7,7 @@ There should only be a single store in your app.
7
7
8
8
1.`reducer`*(Function)*: A [reducing function](../Glossary.md#reducer) that returns the next [state tree](../Glossary.md#state), given the current state tree and an [action](../Glossary.md#action) to handle.
9
9
10
-
2.[`initialState`]*(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.
10
+
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.
11
11
12
12
3.[`enhancer`]*(Function)*: The store enhancer. You may optionally specify it to enhance the store with third-party capabilities such as middleware, time travel, persistence, etc. The only store enhancer that ships with Redux is [`applyMiddleware()`](./applyMiddleware.md).
@@ -83,23 +83,23 @@ function handleRender(req, res) {
83
83
)
84
84
85
85
// Grab the initial state from our Redux store
86
-
constinitialState=store.getState()
86
+
constpreloadedState=store.getState()
87
87
88
88
// Send the rendered page back to the client
89
-
res.send(renderFullPage(html, initialState))
89
+
res.send(renderFullPage(html, preloadedState))
90
90
}
91
91
```
92
92
93
93
### Inject Initial Component HTML and State
94
94
95
-
The final step on the server side is to inject our initial component HTML and initial state into a template to be rendered on the client side. To pass along the state, we add a `<script>` tag that will attach `initialState` to `window.__INITIAL_STATE__`.
95
+
The final step on the server side is to inject our initial component HTML and initial state into a template to be rendered on the client side. To pass along the state, we add a `<script>` tag that will attach `preloadedState` to `window.__PRELOADED_STATE__`.
96
96
97
-
The `initialState` will then be available on the client side by accessing `window.__INITIAL_STATE__`.
97
+
The `preloadedState` will then be available on the client side by accessing `window.__PRELOADED_STATE__`.
98
98
99
99
We also include our bundle file for the client-side application via a script tag. This is whatever output your bundling tool provides for your client entry point. It may be a static file or a URL to a hot reloading development server.
100
100
101
101
```js
102
-
functionrenderFullPage(html, initialState) {
102
+
functionrenderFullPage(html, preloadedState) {
103
103
return`
104
104
<!doctype html>
105
105
<html>
@@ -109,7 +109,7 @@ function renderFullPage(html, initialState) {
@@ -124,7 +124,7 @@ function renderFullPage(html, initialState) {
124
124
125
125
## The Client Side
126
126
127
-
The client side is very straightforward. All we need to do is grab the initial state from `window.__INITIAL_STATE__`, and pass it to our [`createStore()`](../api/createStore.md) function as the initial state.
127
+
The client side is very straightforward. All we need to do is grab the initial state from `window.__PRELOADED_STATE__`, and pass it to our [`createStore()`](../api/createStore.md) function as the initial state.
128
128
129
129
Let’s take a look at our new client file:
130
130
@@ -139,10 +139,10 @@ import App from './containers/App'
139
139
importcounterAppfrom'./reducers'
140
140
141
141
// Grab the state from a global injected into server-generated HTML
@@ -202,7 +202,7 @@ function handleRender(req, res) {
202
202
}
203
203
```
204
204
205
-
The code reads from the Express `Request` object passed into our server middleware. The parameter is parsed into a number and then set in the initial state. If you visit [http://localhost:3000/?counter=100](http://localhost:3000/?counter=100) in your browser, you’ll see the counter starts at 100. In the rendered HTML, you’ll see the counter output as 100 and the `__INITIAL_STATE__` variable has the counter set in it.
205
+
The code reads from the Express `Request` object passed into our server middleware. The parameter is parsed into a number and then set in the initial state. If you visit [http://localhost:3000/?counter=100](http://localhost:3000/?counter=100) in your browser, you’ll see the counter starts at 100. In the rendered HTML, you’ll see the counter output as 100 and the `__PRELOADED_STATE__` variable has the counter set in it.
206
206
207
207
### Async State Fetching
208
208
@@ -245,10 +245,10 @@ function handleRender(req, res) {
0 commit comments