Skip to content

Commit 9005c4a

Browse files
authored
Drop versioned docs entirely (#1696)
1 parent 45dfd45 commit 9005c4a

19 files changed

+249
-425
lines changed

docs/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/api/Provider.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ hide_title: true
99

1010
## Overview
1111

12-
The `<Provider />` makes the Redux `store` available to any nested components that have been wrapped in the `connect()` function.
12+
The `<Provider>` component makes the Redux `store` available to any nested components that need to access the Redux store.
1313

14-
Since any React component in a React Redux app can be connected, most applications will render a `<Provider>` at the top level, with the entire app’s component tree inside of it.
14+
Since any React component in a React Redux app can be connected to the store, most applications will render a `<Provider>` at the top level, with the entire app’s component tree inside of it.
1515

16-
Normally, you can’t use a connected component unless it is nested inside of a `<Provider>`.
16+
The [Hooks](./hooks.md) and [`connect`](./connect.md) APIs can then access the provided store instance via React's Context mechanism.
1717

1818
### Props
1919

@@ -30,29 +30,12 @@ You may provide a context instance. If you do so, you will need to provide the s
3030
>
3131
> Could not find "store" in the context of "Connect(MyComponent)". Either wrap the root component in a `<Provider>`, or pass a custom React context provider to `<Provider>` and the corresponding React context consumer to Connect(Todo) in connect options.
3232
33-
**Note:** You do not need to provide custom context in order to access the store.
34-
React Redux exports the context instance it uses by default so that you can access the store by:
35-
36-
```js
37-
import { ReactReduxContext } from 'react-redux'
38-
39-
// in your connected component
40-
render() {
41-
return (
42-
<ReactReduxContext.Consumer>
43-
{({ store }) => {
44-
// do something with the store here
45-
}}
46-
</ReactReduxContext.Consumer>
47-
)
48-
}
49-
```
33+
5034

5135
### Example Usage
5236

5337
In the example below, the `<App />` component is our root-level component. This means it’s at the very top of our component hierarchy.
5438

55-
**Vanilla React Example**
5639

5740
```jsx
5841
import React from 'react'
@@ -72,29 +55,3 @@ ReactDOM.render(
7255
)
7356
```
7457

75-
**Usage with React Router**
76-
77-
```jsx
78-
import React from 'react'
79-
import ReactDOM from 'react-dom'
80-
import { Provider } from 'react-redux'
81-
import { Router, Route } from 'react-router-dom'
82-
83-
import { App } from './App'
84-
import { Foo } from './Foo'
85-
import { Bar } from './Bar'
86-
import createStore from './createReduxStore'
87-
88-
const store = createStore()
89-
90-
ReactDOM.render(
91-
<Provider store={store}>
92-
<Router history={history}>
93-
<Route exact path="/" component={App} />
94-
<Route path="/foo" component={Foo} />
95-
<Route path="/bar" component={Bar} />
96-
</Router>
97-
</Provider>,
98-
document.getElementById('root')
99-
)
100-
```

docs/api/batch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ hide_title: true
1111
batch((fn: Function))
1212
```
1313

14+
*added in v7.0.0*
15+
1416
React's `unstable_batchedUpdates()` API allows any React updates in an event loop tick to be batched together into a single render pass. React already uses this internally for its own event handler callbacks. This API is actually part of the renderer packages like ReactDOM and React Native, not the React core itself.
1517

1618
Since React-Redux needs to work in both ReactDOM and React Native environments, we've taken care of importing this API from the correct renderer at build time for our own use. We also now re-export this function publicly ourselves, renamed to `batch()`. You can use it to ensure that multiple actions dispatched outside of React only result in a single render update, like this:

docs/api/connect-advanced.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ It does not modify the component class passed to it; instead, it _returns_ a new
1717
1818
Most applications will not need to use this, as the default behavior in `connect` is intended to work for most use cases.
1919
20-
> Note: `connectAdvanced` was added in version 5.0, and `connect` was reimplemented as a specific set of parameters to `connectAdvanced`.
20+
:::info
21+
22+
`connectAdvanced` was added in version 5.0, and `connect` was reimplemented as a specific set of parameters to `connectAdvanced`. However, [**`connectAdvanced` is now deprecated**](https://github.com/reduxjs/react-redux/issues/1236) and will eventually be removed in a future major version of React Redux.
23+
24+
:::
25+
2126
2227
## Arguments
2328

docs/api/connect.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,13 @@ const makeMapState = (state) => {
577577
}
578578
export default connect(makeMapState)(SomeComponent)
579579
```
580+
581+
582+
## Legacy Version Docs
583+
584+
While the `connect` API has stayed almost entirely API-compatible between all of our major versions, there have been some small changes in options and behavior from version to version.
585+
586+
For details on the legacy 5.x and 6.x versions, please see these archived files in the React Redux repo:
587+
588+
- [5.x `connect` API reference](https://github.com/reduxjs/react-redux/blob/v7.2.2/website/versioned_docs/version-5.x/api/connect.md)
589+
- [6.x `connect` API reference](https://github.com/reduxjs/react-redux/blob/v7.2.2/website/versioned_docs/version-6.x/api/connect.md)

docs/api/hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ hide_title: true
77

88
# Hooks
99

10-
React's new ["hooks" APIs](https://reactjs.org/docs/hooks-intro.html) give function components the ability to use local component state, execute side effects, and more.
10+
React's new ["hooks" APIs](https://reactjs.org/docs/hooks-intro.html) give function components the ability to use local component state, execute side effects, and more. React also lets us write [custom hooks](https://reactjs.org/docs/hooks-custom.html), which let us extract reusable hooks to add our own behavior on top of React's built-in hooks.
1111

12-
React Redux now offers a set of hook APIs as an alternative to the existing `connect()` Higher Order Component. These APIs allow you to subscribe to the Redux store and dispatch actions, without having to wrap your components in `connect()`.
12+
React Redux includes its own custom hook APIs, which allow your React components to subscribe to the Redux store and dispatch actions.
1313

1414
:::tip
1515

docs/introduction/getting-started.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
id: getting-started
3+
title: Getting Started
4+
hide_title: true
5+
sidebar_label: Getting Started
6+
---
7+
8+
# Getting Started with React Redux
9+
10+
[React Redux](https://github.com/reduxjs/react-redux) is the official [React](https://reactjs.org/) UI bindings layer for [Redux](https://redux.js.org/). It lets your React components read data from a Redux store, and dispatch actions to the store to update state.
11+
12+
## Installation
13+
14+
React Redux 7.1+ requires **React 16.8.3 or later**, in order to make use of React Hooks.
15+
16+
### Using Create React App
17+
18+
The recommended way to start new apps with React Redux is by using the [official Redux+JS template](https://github.com/reduxjs/cra-template-redux) for [Create React App](https://github.com/facebook/create-react-app), which takes advantage of [Redux Toolkit](https://redux-toolkit.js.org/).
19+
20+
```sh
21+
npx create-react-app my-app --template redux
22+
```
23+
24+
### An Existing React App
25+
26+
To use React Redux with your React app, install it as a dependency:
27+
28+
```bash
29+
# If you use npm:
30+
npm install react-redux
31+
32+
# Or if you use Yarn:
33+
yarn add react-redux
34+
```
35+
36+
You'll also need to [install Redux](https://redux.js.org/introduction/installation) and [set up a Redux store](https://redux.js.org/recipes/configuring-your-store/) in your app.
37+
38+
If you are using TypeScript, the React Redux types are maintained separately in DefinitelyTyped. You'll need to install those as well:
39+
40+
```bash
41+
npm install @types/react-redux
42+
```
43+
44+
## `Provider`
45+
46+
React Redux includes a `<Provider />` component, which makes the Redux store available to the rest of your app:
47+
48+
```js
49+
import React from 'react'
50+
import ReactDOM from 'react-dom'
51+
52+
import { Provider } from 'react-redux'
53+
import store from './store'
54+
55+
import App from './App'
56+
57+
const rootElement = document.getElementById('root')
58+
ReactDOM.render(
59+
<Provider store={store}>
60+
<App />
61+
</Provider>,
62+
rootElement
63+
)
64+
```
65+
66+
## Hooks
67+
68+
React Redux provides a pair of custom React hooks that allow your React components to interact with the Redux store.
69+
70+
`useSelector` reads a value from the store state and subscribes to updates, while `useDispatch` returns the store's `dispatch` method to let you dispatch actions.
71+
72+
```js
73+
import React, { useState } from 'react'
74+
import { useSelector, useDispatch } from 'react-redux'
75+
import {
76+
decrement,
77+
increment,
78+
incrementByAmount,
79+
incrementAsync,
80+
selectCount
81+
} from './counterSlice'
82+
import styles from './Counter.module.css'
83+
84+
export function Counter() {
85+
const count = useSelector(selectCount)
86+
const dispatch = useDispatch()
87+
const [incrementAmount, setIncrementAmount] = useState('2')
88+
89+
return (
90+
<div>
91+
<div className={styles.row}>
92+
<button
93+
className={styles.button}
94+
aria-label="Increment value"
95+
onClick={() => dispatch(increment())}
96+
>
97+
+
98+
</button>
99+
<span className={styles.value}>{count}</span>
100+
<button
101+
className={styles.button}
102+
aria-label="Decrement value"
103+
onClick={() => dispatch(decrement())}
104+
>
105+
-
106+
</button>
107+
</div>
108+
{/* omit additional rendering output here */}
109+
</div>
110+
)
111+
}
112+
```
113+
114+
## Help and Discussion
115+
116+
The **[#redux channel](https://discord.gg/0ZcbPKXt5bZ6au5t)** of the **[Reactiflux Discord community](http://www.reactiflux.com)** is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!
117+
118+
You can also ask questions on [Stack Overflow](https://stackoverflow.com) using the **[#redux tag](https://stackoverflow.com/questions/tagged/redux)**.
119+
120+
## Docs Translations
121+
122+
- [Portuguese](https://fernandobelotto.github.io/react-redux)

docs/introduction/quick-start.md

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)