Skip to content

Commit dde1a0a

Browse files
wgao19markerikson
authored andcommitted
Clean-Ups after mapState (#1042)
## What does this PR do? Regarding #1001, a few follow up fixes on the `mapState` piece. ## Summary of the changes - Site header: - Remove "Troubleshooting" - Uppercase "API" - Add "Using React-Redux" and let it direct to the `mapState` doc - Site sidebar: - Uppercase "API" - Add a dash to "React-Redux" - Site footer: - Add "Using React-Redux" - Align all link labels with section names on the sidebar - Doc changes - `<ConnectedTodo>` typo - Changed a wording at the table for consistency - Add "./using-react-redux" directory and move in mapState.md - Add `array.slice` to the list of options that create new references
1 parent 294c42c commit dde1a0a

File tree

7 files changed

+25
-29
lines changed

7 files changed

+25
-29
lines changed

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- [Getting Started: adding React-Redux to a React todo app](./getting-started.md)
44
- Using React-Redux
5-
- [Connect: Extracting Data with `mapStateToProps`](./connect-extracting-data-with-mapStateToProps.md)
5+
- [Connect: Extracting Data with `mapStateToProps`](./using-react-redux/connect-extracting-data-with-mapStateToProps.md)
66
- [API](api.md#api)
77
- [`<Provider store>`](api.md#provider-store)
88
- [`connect([mapStateToProps], [mapDispatchToProps], [mergeProps], [options])`](api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options)

docs/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: api
33
title: Api
4-
sidebar_label: Api
4+
sidebar_label: API
55
hide_title: true
66
---
77

docs/getting-started.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Our `addTodo` action creator looks like this:
187187

188188
```js
189189
// redux/actions.js
190-
import { ADD_TODO } from './actionTypes';
190+
import { ADD_TODO } from "./actionTypes";
191191

192192
let nextTodoId = 0;
193193
export const addTodo = content => ({
@@ -497,7 +497,6 @@ Now we've finished a very simple example of a todo app with React-Redux. All our
497497
- [Usage with React](https://redux.js.org/basics/usagewithreact)
498498
- [Using the React-Redux Bindings](https://blog.isquaredsoftware.com/presentations/workshops/redux-fundamentals/react-redux.html)
499499
- [Higher Order Components in Depth](https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e)
500-
<!-- - [Presentational and Container Components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0) -->
501500
- [Computing Derived Data](https://redux.js.org/recipes/computingderiveddata#sharing-selectors-across-multiple-components)
502501
- [Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance](https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/)
503502

docs/connect-extracting-data-with-mapStateToProps.md renamed to docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ To summarize the behavior of the component wrapped by `connect` with `mapStateTo
131131
132132
| | `(state) => stateProps` | `(state, ownProps) => stateProps` |
133133
| ---------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------- |
134-
| `mapStateToProps` runs when: | store `state` is `===` different | store `state` changes <br /> or <br />any field of `ownProps` is different |
134+
| `mapStateToProps` runs when: | store `state` changes | store `state` changes <br /> or <br />any field of `ownProps` is different |
135135
| component re-renders when: | any field of `stateProps` is different | any field of `stateProps` is different <br /> or <br /> any field of `ownProps` is different |
136136
137137
@@ -143,6 +143,7 @@ Many common operations result in new object or array references being created:
143143
144144
- Creating new arrays with `someArray.map()` or `someArray.filter()`
145145
- Merging arrays with `array.concat`
146+
- Selecting portion of an array with `array.slice`
146147
- Copying values with `Object.assign`
147148
- Copying values with the spread operator `{ ...oldState, ...newData }`
148149
@@ -223,16 +224,6 @@ function mapStateToProps(...args) {
223224
}
224225
```
225226
226-
227-
228-
229-
<!--
230-
## Next Up
231-
- Connect: Dispatching Actions with `mapDispatchToProps`
232-
- Further optimizing `mapStateToProps` performances by writing memoized selectors or using Reselect →
233-
- Understanding whys and hows →
234-
-->
235-
236227
## Links and References
237228
238229
**Tutorials**

website/core/Footer.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ class Footer extends React.Component {
3434
</a>
3535
<div>
3636
<h5>Docs</h5>
37-
<a href={this.docUrl("getting-started")}>
38-
Getting Started
39-
</a>
40-
<a href={this.docUrl("api")}>
41-
Api
42-
</a>
43-
<a href={this.docUrl("troubleshooting")}>
44-
Troubleshooting
37+
<a href={this.docUrl("getting-started")}>Introduction</a>
38+
<a
39+
href={this.docUrl(
40+
"using-react-redux/connect-extracting-data-with-mapStateToProps"
41+
)}
42+
>
43+
Using React-Redux
4544
</a>
45+
<a href={this.docUrl("api")}>API Reference</a>
46+
<a href={this.docUrl("troubleshooting")}>Guides</a>
4647
</div>
4748
<div>
4849
<h5>Community</h5>

website/sidebars.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"docs": {
33
"Introduction": ["getting-started"],
4-
"Using React Redux": ["connect-extracting-data-with-mapStateToProps"],
4+
"Using React-Redux": [
5+
"using-react-redux/connect-extracting-data-with-mapStateToProps"
6+
],
57
"API Reference": ["api", "api/provider"],
68
"Guides": ["troubleshooting"]
79
}

website/siteConfig.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ const siteConfig = {
2626

2727
// For no header links in the top nav bar -> headerLinks: [],
2828
headerLinks: [
29-
{ doc: "getting-started", label: "Getting started" },
30-
{ doc: "api", label: "Api" },
31-
{ doc: "troubleshooting", label: "Troubleshooting" }
29+
{ doc: "getting-started", label: "Getting Started" },
30+
{
31+
doc: "using-react-redux/connect-extracting-data-with-mapStateToProps",
32+
label: "Using React-Redux"
33+
},
34+
{ doc: "api", label: "API" }
3235
],
3336

3437
/* path to images for header/footer */
@@ -39,7 +42,7 @@ const siteConfig = {
3942
/* Colors for website */
4043
colors: {
4144
primaryColor: "#764ABC",
42-
secondaryColor: "#764ABC",
45+
secondaryColor: "#764ABC"
4346
},
4447

4548
/* Custom fonts for website */
@@ -78,7 +81,7 @@ const siteConfig = {
7881

7982
// You may provide arbitrary config keys to be used as needed by your
8083
// template. For example, if you need your repo's URL...
81-
repoUrl: "https://github.com/reduxjs/react-redux",
84+
repoUrl: "https://github.com/reduxjs/react-redux"
8285
};
8386

8487
module.exports = siteConfig;

0 commit comments

Comments
 (0)