Skip to content

Commit 1a1c7ac

Browse files
xphongtimdorr
authored andcommitted
fix(docs): fix toc links in faq and recipes (#3158)
1 parent 5014dcc commit 1a1c7ac

12 files changed

+114
-170
lines changed

docs/FAQ.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,59 @@
88
- [Can Redux only be used with React?](/docs/faq/General.md#can-redux-only-be-used-with-react)
99
- [Do I need to have a particular build tool to use Redux?](/docs/faq/General.md#do-i-need-to-have-a-particular-build-tool-to-use-redux)
1010
- **Reducers**
11-
- [How do I share state between two reducers? Do I have to use combineReducers?](/docs/faq/Reducers.md#reducers-share-state)
12-
- [Do I have to use the switch statement to handle actions?](/docs/faq/Reducers.md#reducers-use-switch)
11+
- [How do I share state between two reducers? Do I have to use combineReducers?](/docs/faq/Reducers.md#how-do-i-share-state-between-two-reducers-do-i-have-to-use-combinereducers)
12+
- [Do I have to use the switch statement to handle actions?](/docs/faq/Reducers.md#do-i-have-to-use-the-switch-statement-to-handle-actions)
1313
- **Organizing State**
14-
- [Do I have to put all my state into Redux? Should I ever use React's setState()?](/docs/faq/OrganizingState.md#organizing-state-only-redux-state)
15-
- [Can I put functions, promises, or other non-serializable items in my store state?](/docs/faq/OrganizingState.md#organizing-state-non-serializable)
16-
- [How do I organize nested or duplicate data in my state?](/docs/faq/OrganizingState.md#organizing-state-nested-data)
14+
- [Do I have to put all my state into Redux? Should I ever use React's setState()?](/docs/faq/OrganizingState.md#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate)
15+
- [Can I put functions, promises, or other non-serializable items in my store state?](/docs/faq/OrganizingState.md#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
16+
- [How do I organize nested or duplicate data in my state?](/docs/faq/OrganizingState.md#how-do-i-organize-nested-or-duplicate-data-in-my-state)
1717
- **Store Setup**
18-
- [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](/docs/faq/StoreSetup.md#store-setup-multiple-stores)
19-
- [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](/docs/faq/StoreSetup.md#store-setup-middleware-chains)
20-
- [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](/docs/faq/StoreSetup.md#store-setup-subscriptions)
18+
- [Can or should I create multiple stores? Can I import my store directly, and use it in components myself?](/docs/faq/StoreSetup.md#can-or-should-i-create-multiple-stores-can-i-import-my-store-directly-and-use-it-in-components-myself)
19+
- [Is it OK to have more than one middleware chain in my store enhancer? What is the difference between next and dispatch in a middleware function?](/docs/faq/StoreSetup.md#is-it-ok-to-have-more-than-one-middleware-chain-in-my-store-enhancer-what-is-the-difference-between-next-and-dispatch-in-a-middleware-function)
20+
- [How do I subscribe to only a portion of the state? Can I get the dispatched action as part of the subscription?](/docs/faq/StoreSetup.md#how-do-i-subscribe-to-only-a-portion-of-the-state-can-i-get-the-dispatched-action-as-part-of-the-subscription)
2121
- **Actions**
22-
- [Why should type be a string, or at least serializable? Why should my action types be constants?](/docs/faq/Actions.md#actions-string-constants)
23-
- [Is there always a one-to-one mapping between reducers and actions?](/docs/faq/Actions.md#actions-reducer-mappings)
24-
- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](/docs/faq/Actions.md#actions-side-effects)
25-
- [Should I dispatch multiple actions in a row from one action creator?](/docs/faq/Actions.md#actions-multiple-actions)
22+
- [Why should type be a string, or at least serializable? Why should my action types be constants?](/docs/Actions.md#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
23+
- [Is there always a one-to-one mapping between reducers and actions?](/docs/Actions.md#is-there-always-a-one-to-one-mapping-between-reducers-and-actions)
24+
- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](/docs/Actions.md#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behavior)
25+
- [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](/docs/Actions.md#what-async-middleware-should-i-use-how-do-you-decide-between-thunks-sagas-observables-or-something-else)
26+
- [Should I dispatch multiple actions in a row from one action creator?](/docs/Actions.md#should-i-dispatch-multiple-actions-in-a-row-from-one-action-creator)
2627
- **Immutable Data**
27-
- [What are the benefits of Immutability?](/docs/faq/ImmutableData.md#benefits-of-immutability)
28-
- [Why is immutability required in Redux?](/docs/faq/ImmutableData.md#why-is-immutability-required)
29-
- [Do I have to use Immutable.JS?](/docs/faq/ImmutableData.md#do-i-have-to-use-immutable-js)
30-
- [What are the issues with using ES6 for immutable operations?](/docs/faq/ImmutableData.md#issues-with-es6-for-immutable-ops)
28+
- [What are the benefits of immutability?](/docs/ImmutableData.md#what-are-the-benefits-of-immutability)
29+
- [Why is immutability required by Redux?](/docs/ImmutableData.md#why-is-immutability-required-by-redux)
30+
- [What approaches are there for handling data immutability? Do I have to use Immutable.JS?](/docs/ImmutableData.md#what-approaches-are-there-for-handling-data-immutability-do-i-have-to-use-immutable-js)
31+
- [What are the issues with using JavaScript for immutable operations?](/docs/ImmutableData.md#what-are-the-issues-with-using-plain-javascript-for-immutable-operations)
3132
- **Using Immutable.JS with Redux**
32-
- [Why should I use an immutable-focused library such as Immutable.JS?](/docs/recipes/UsingImmutableJS.md#why-use-immutable-library)
33-
- [Why should I choose Immutable.JS as an immutable library?](/docs/recipes/UsingImmutableJS.md#why-choose-immutable-js)
34-
- [What are the issues with using Immutable.JS?](/docs/recipes/UsingImmutableJS.md#issues-with-immutable-js)
35-
- [Is Immutable.JS worth the effort?](/docs/recipes/UsingImmutableJS.md#is-immutable-js-worth-effort)
36-
- [What are some opinionated Best Practices for using Immutable.JS with Redux?](/docs/recipes/UsingImmutableJS.md#immutable-js-best-practices)
33+
- [Why should I use an immutable-focused library such as Immutable.JS?](/docs/recipes/UsingImmutableJS.md#why-should-i-use-an-immutable-focused-library-such-as-immutable-js)
34+
- [Why should I choose Immutable.JS as an immutable library?](/docs/recipes/UsingImmutableJS.md#why-should-i-choose-immutable-js-as-an-immutable-library)
35+
- [What are the issues with using Immutable.JS?](/docs/recipes/UsingImmutableJS.md#what-are-the-issues-with-using-immutable-js)
36+
- [Is Immutable.JS worth the effort?](/docs/recipes/UsingImmutableJS.md#is-using-immutable-js-worth-the-effort)
37+
- [What are some opinionated Best Practices for using Immutable.JS with Redux?](/docs/recipes/UsingImmutableJS.md#what-are-some-opinionated-best-practices-for-using-immutable-js-with-redux)
3738

3839
- **Code Structure**
39-
- [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](/docs/faq/CodeStructure.md#structure-file-structure)
40-
- [How should I split my logic between reducers and action creators? Where should my “business logic” go?](/docs/faq/CodeStructure.md#structure-business-logic)
41-
- [Why should I use action creators?](/docs/faq/CodeStructure.md#structure-action-creators)
40+
- [What should my file structure look like? How should I group my action creators and reducers in my project? Where should my selectors go?](/docs/faq/CodeStructure.md#what-should-my-file-structure-look-like-how-should-i-group-my-action-creators-and-reducers-in-my-project-where-should-my-selectors-go)
41+
- [How should I split my logic between reducers and action creators? Where should my “business logic” go?](/docs/faq/CodeStructure.md#how-should-i-split-my-logic-between-reducers-and-action-creators-where-should-my-business-logic-go)
42+
- [Why should I use action creators?](/docs/faq/CodeStructure.md#why-should-i-use-action-creators)
43+
- [Where should websockets and other persistent connections live?](/docs/faq/CodeStructure.md#where-should-websockets-and-other-persistent-connections-live)
4244
- **Performance**
43-
- [How well does Redux “scale” in terms of performance and architecture?](/docs/faq/Performance.md#performance-scaling)
44-
- [Won't calling “all my reducers” for each action be slow?](/docs/faq/Performance.md#performance-all-reducers)
45-
- [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](/docs/faq/Performance.md#performance-clone-state)
46-
- [How can I reduce the number of store update events?](/docs/faq/Performance.md#performance-update-events)
47-
- [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](/docs/faq/Performance.md#performance-state-memory)
48-
- [Will caching remote data cause memory problems?](/docs/faq/Performance.md#performance-cache-memory)
45+
- [How well does Redux “scale” in terms of performance and architecture?](/docs/faq/Performance.md#how-well-does-redux-scale-in-terms-of-performance-and-architecture)
46+
- [Won't calling “all my reducers” for each action be slow?](/docs/faq/Performance.md#wont-calling-all-my-reducers-for-each-action-be-slow)
47+
- [Do I have to deep-clone my state in a reducer? Isn't copying my state going to be slow?](/docs/faq/Performance.md#do-i-have-to-deep-clone-my-state-in-a-reducer-isnt-copying-my-state-going-to-be-slow)
48+
- [How can I reduce the number of store update events?](/docs/faq/Performance.md#how-can-i-reduce-the-number-of-store-update-events)
49+
- [Will having “one state tree” cause memory problems? Will dispatching many actions take up memory?](/docs/faq/Performance.md#will-having-one-state-tree-cause-memory-problems-will-dispatching-many-actions-take-up-memory)
50+
- [Will caching remote data cause memory problems?](/docs/faq/Performance.md#will-caching-remote-data-cause-memory-problems)
4951
- **Design Decisions**
50-
- [Why doesn't Redux pass the state and action to subscribers?](/docs/faq/DesignDecisions.md#does-not-pass-state-action-to-subscribers)
51-
- [Why doesn't Redux support using classes for actions and reducers?](/docs/faq/DesignDecisions.md#does-not-support-classes)
52-
- [Why does the middleware signature use currying?](/docs/faq/DesignDecisions.md#why-currying)
53-
- [Why does applyMiddleware use a closure for dispatch?](/docs/faq/DesignDecisions.md#closure-dispatch)
54-
- [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](/docs/faq/DesignDecisions.md#combineReducers-limitations)
55-
- [Why doesn't `mapDispatchToProps` allow use of return values from `getState()` or `mapStateToProps()`?](/docs/faq/DesignDecisions.md#no-asynch-in-mapDispatchToProps)
52+
- [Why doesn't Redux pass the state and action to subscribers?](/docs/faq/DesignDecisions.md#why-doesnt-redux-pass-the-state-and-action-to-subscribers)
53+
- [Why doesn't Redux support using classes for actions and reducers?](/docs/faq/DesignDecisions.md#why-doesnt-redux-support-using-classes-for-actions-and-reducers)
54+
- [Why does the middleware signature use currying?](/docs/faq/DesignDecisions.md#why-does-the-middleware-signature-use-currying)
55+
- [Why does applyMiddleware use a closure for dispatch?](/docs/faq/DesignDecisions.md#why-does-applymiddleware-use-a-closure-for-dispatch)
56+
- [Why doesn't `combineReducers` include a third argument with the entire state when it calls each reducer?](/docs/faq/DesignDecisions.md#why-doesnt-combinereducers-include-a-third-argument-with-the-entire-state-when-it-calls-each-reducer)
57+
- [Why doesn't mapDispatchToProps allow use of return values from `getState()` or `mapStateToProps()`?](/docs/faq/DesignDecisions.md#why-doesnt-mapdispatchtoprops-allow-use-of-return-values-from-getstate-or-mapstatetoprops)
5658
- **React Redux**
57-
- [Why isn't my component re-rendering, or my mapStateToProps running?](/docs/faq/ReactRedux.md#react-not-rerendering)
58-
- [Why is my component re-rendering too often?](/docs/faq/ReactRedux.md#react-rendering-too-often)
59-
- [How can I speed up my mapStateToProps?](/docs/faq/ReactRedux.md#react-mapstate-speed)
60-
- [Why don't I have this.props.dispatch available in my connected component?](/docs/faq/ReactRedux.md#react-props-dispatch)
61-
- [Should I only connect my top component, or can I connect multiple components in my tree?](/docs/faq/ReactRedux.md#react-multiple-components)
59+
- [Why isn't my component re-rendering, or my mapStateToProps running?](/docs/faq/ReactRedux.md#why-isnt-my-component-re-rendering-or-my-mapstatetoprops-running)
60+
- [Why is my component re-rendering too often?](/docs/faq/ReactRedux.md#why-is-my-component-re-rendering-too-often)
61+
- [How can I speed up my mapStateToProps?](/docs/faq/ReactRedux.md#how-can-i-speed-up-my-mapstatetoprops)
62+
- [Why don't I have this.props.dispatch available in my connected component?](/docs/faq/ReactRedux.md#why-dont-i-have-this-props-dispatch-available-in-my-connected-component)
63+
- [Should I only connect my top component, or can I connect multiple components in my tree?](/docs/faq/ReactRedux.md#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree)
6264
- **Miscellaneous**
63-
- [Are there any larger, “real” Redux projects?](/docs/faq/Miscellaneous.md#miscellaneous-real-projects)
64-
- [How can I implement authentication in Redux?](/docs/faq/Miscellaneous.md#miscellaneous-authentication)
65+
- [Are there any larger, “real” Redux projects?](/docs/faq/Miscellaneous.md#are-there-any-larger-real-redux-projects)
66+
- [How can I implement authentication in Redux?](/docs/faq/Miscellaneous.md#how-can-i-implement-authentication-in-redux)

docs/faq/Actions.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
## Table of Contents
44

5-
- [Why should type be a string, or at least serializable? Why should my action types be constants?](#actions-string-constants)
6-
- [Is there always a one-to-one mapping between reducers and actions?](#actions-reducer-mappings)
7-
- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](#actions-side-effects)
8-
- [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](#actions-async-middlewares)
9-
- [Should I dispatch multiple actions in a row from one action creator?](#actions-multiple-actions)
5+
- [Why should type be a string, or at least serializable? Why should my action types be constants?](#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
6+
- [Is there always a one-to-one mapping between reducers and actions?](#is-there-always-a-one-to-one-mapping-between-reducers-and-actions)
7+
- [How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?](#how-can-i-represent-side-effects-such-as-ajax-calls-why-do-we-need-things-like-action-creators-thunks-and-middleware-to-do-async-behavior)
8+
- [What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?](#what-async-middleware-should-i-use-how-do-you-decide-between-thunks-sagas-observables-or-something-else)
9+
- [Should I dispatch multiple actions in a row from one action creator?](#should-i-dispatch-multiple-actions-in-a-row-from-one-action-creator)
1010

1111

1212
## Actions
1313

14-
<a id="actions-string-constants"></a>
1514
### Why should `type` be a string, or at least serializable? Why should my action types be constants?
1615

1716
As with state, serializable actions enable several of Redux's defining features, such as time travel debugging, and recording and replaying actions. Using something like a `Symbol` for the `type` value or using `instanceof` checks for actions themselves would break that. Strings are serializable and easily self-descriptive, and so are a better choice. Note that it *is* okay to use Symbols, Promises, or other non-serializable values in an action if the action is intended for use by middleware. Actions only need to be serializable by the time they actually reach the store and are passed to the reducers.
@@ -34,7 +33,6 @@ Encapsulating and centralizing commonly used pieces of code is a key concept in
3433
- [Stack Overflow: What is the point of the constants in Redux?](http://stackoverflow.com/q/34965856/62937)
3534

3635

37-
<a id="actions-reducer-mappings"></a>
3836
### Is there always a one-to-one mapping between reducers and actions?
3937

4038
No. We suggest you write independent small reducer functions that are each responsible for updates to a specific slice of state. We call this pattern “reducer composition”. A given action could be handled by all, some, or none of them. This keeps components decoupled from the actual data changes, as one action may affect different parts of the state tree, and there is no need for the component to be aware of this. Some users do choose to bind them more tightly together, such as the “ducks” file structure, but there is definitely no one-to-one mapping by default, and you should break out of such a paradigm any time you feel you want to handle an action in many reducers.
@@ -52,7 +50,6 @@ No. We suggest you write independent small reducer functions that are each respo
5250
- [Stack Overflow: Can I dispatch multiple actions without Redux Thunk middleware?](http://stackoverflow.com/questions/35493352/can-i-dispatch-multiple-actions-without-redux-thunk-middleware/35642783)
5351

5452

55-
<a id="actions-side-effects"></a>
5653
### How can I represent “side effects” such as AJAX calls? Why do we need things like “action creators”, “thunks”, and “middleware” to do async behavior?
5754

5855
This is a long and complex topic, with a wide variety of opinions on how code should be organized and what approaches should be used.
@@ -94,7 +91,6 @@ The simplest and most common way to do this is to add the [Redux Thunk](https://
9491
- [Reddit: Help performing Async API calls with Redux-Promise Middleware.](https://www.reddit.com/r/reactjs/comments/469iyc/help_performing_async_api_calls_with_reduxpromise/)
9592
- [Twitter: possible comparison between sagas, loops, and other approaches](https://twitter.com/dan_abramov/status/689639582120415232)
9693

97-
<a id="actions-async-middlewares"></a>
9894
### What async middleware should I use? How do you decide between thunks, sagas, observables, or something else?
9995

10096
There are [many async/side effect middlewares available](https://github.com/markerikson/redux-ecosystem-links/blob/master/side-effects.md), but the most commonly used ones are [`redux-thunk`](https://github.com/reduxjs/redux-thunk), [`redux-saga`](https://github.com/redux-saga/redux-saga), and [`redux-observable`](https://github.com/redux-observable/redux-observable). These are different tools, with different strengths, weaknesses, and use cases.
@@ -125,7 +121,6 @@ Since sagas and observables have the same use case, an application would normall
125121
- [Stack Overflow: Why use Redux-Observable over Redux-Saga?](https://stackoverflow.com/questions/40021344/why-use-redux-observable-over-redux-saga/40027778#40027778)
126122

127123

128-
<a id="actions-multiple-actions"></a>
129124
### Should I dispatch multiple actions in a row from one action creator?
130125

131126
There's no specific rule for how you should structure your actions. Using an async middleware like Redux Thunk certainly enables scenarios such as dispatching multiple distinct but related actions in a row, dispatching actions to represent progression of an AJAX request, dispatching actions conditionally based on state, or even dispatching an action and checking the updated state immediately afterwards.

0 commit comments

Comments
 (0)