Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: reduxjs/react-redux
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.2.2
Choose a base ref
...
head repository: reduxjs/react-redux
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.2.3
Choose a head ref
  • 20 commits
  • 44 files changed
  • 14 contributors

Commits on Oct 30, 2020

  1. Doc : Update ownProps example (#1655)

    This changes can make more clear understanding to future reader.
    harshilparmar authored Oct 30, 2020
    Copy the full SHA
    1769d24 View commit details

Commits on Nov 1, 2020

  1. Copy the full SHA
    7b0a678 View commit details

Commits on Nov 3, 2020

  1. Update hooks.md (#1659)

    JimmyLv authored Nov 3, 2020
    Copy the full SHA
    94fcab6 View commit details

Commits on Nov 11, 2020

  1. Update quick-start.md (#1663)

    Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
    Sahil Purav and timdorr authored Nov 11, 2020
    Copy the full SHA
    b48d087 View commit details

Commits on Dec 8, 2020

  1. Copy the full SHA
    0e71c05 View commit details
  2. Copy the full SHA
    5abf1be View commit details

Commits on Dec 11, 2020

  1. Bump ini from 1.3.5 to 1.3.7 in /website (#1669)

    Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
    - [Release notes](https://github.com/isaacs/ini/releases)
    - [Commits](npm/ini@v1.3.5...v1.3.7)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 11, 2020
    Copy the full SHA
    2d22c65 View commit details

Commits on Dec 12, 2020

  1. Copy the full SHA
    48773fd View commit details

Commits on Dec 21, 2020

  1. Copy the full SHA
    98b6626 View commit details

Commits on Dec 23, 2020

  1. Bump node-notifier from 8.0.0 to 8.0.1 (#1672)

    Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
    - [Release notes](https://github.com/mikaelbr/node-notifier/releases)
    - [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
    - [Commits](mikaelbr/node-notifier@v8.0.0...v8.0.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 23, 2020
    Copy the full SHA
    1f07ec1 View commit details
  2. Copy the full SHA
    96bf941 View commit details

Commits on Jan 3, 2021

  1. added docs translations section in quick start (#1675)

    Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
    fernandobelotto and timdorr authored Jan 3, 2021
    Copy the full SHA
    80f8fe1 View commit details
  2. Added translation section to docs version 7.2 (#1676)

    * added docs translations section in quick start
    
    Added translation section and link to the docs translated to brazilian portuguese
    
    * Simplify
    
    * adding translation section to version 7.2
    
    Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
    fernandobelotto and timdorr authored Jan 3, 2021
    Copy the full SHA
    a923553 View commit details

Commits on Feb 22, 2021

  1. Copy the full SHA
    45dfd45 View commit details

Commits on Mar 20, 2021

  1. Copy the full SHA
    9005c4a View commit details

Commits on Mar 21, 2021

  1. Copy the full SHA
    86b6fe0 View commit details

Commits on Mar 22, 2021

  1. Copy the full SHA
    3aa8993 View commit details
  2. Reuse latest selected state on selector re-run (#1654) (#1660)

    Co-authored-by: nightpool <nightpool@users.noreply.github.com>
    Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
    3 people authored Mar 22, 2021
    Copy the full SHA
    65b4a16 View commit details

Commits on Mar 23, 2021

  1. Copy the full SHA
    da22052 View commit details
  2. 7.2.3

    markerikson committed Mar 23, 2021
    Copy the full SHA
    a87cd5f View commit details
Showing with 6,249 additions and 6,232 deletions.
  1. +2 −1 .prettierrc
  2. +0 −12 docs/README.md
  3. +4 −47 docs/api/Provider.md
  4. +2 −0 docs/api/batch.md
  5. +6 −1 docs/api/connect-advanced.md
  6. +10 −0 docs/api/connect.md
  7. +95 −47 docs/api/hooks.md
  8. +122 −0 docs/introduction/getting-started.md
  9. +0 −87 docs/introduction/quick-start.md
  10. +2 −2 docs/introduction/why-use-react-redux.md
  11. +3 −58 docs/troubleshooting.md
  12. +12 −4 docs/{introduction/basic-tutorial.md → tutorials/connect.md}
  13. +19 −9 docs/using-react-redux/accessing-store.md
  14. +2 −1 docs/using-react-redux/connect-extracting-data-with-mapStateToProps.md
  15. +128 −101 docs/using-react-redux/{static-types.md → usage-with-typescript.md}
  16. +55 −20 package-lock.json
  17. +2 −1 package.json
  18. +3 −2 src/components/Provider.js
  19. +10 −1 src/hooks/useSelector.js
  20. +29 −0 test/hooks/useSelector.spec.js
  21. +21 −0 website/.gitignore
  22. +17 −0 website/_redirects
  23. +50 −53 website/docusaurus.config.js
  24. +5,335 −5,473 website/package-lock.json
  25. +2 −2 website/package.json
  26. +46 −0 website/sidebars.js
  27. +0 −23 website/sidebars.json
  28. +0 −115 website/src/pages/_versions.js
  29. +27 −45 website/src/pages/index.js
  30. +36 −7 website/static/css/custom.css
  31. +2 −2 website/versioned_docs/version-5.x/introduction/why-use-react-redux.md
  32. +3 −7 website/versioned_docs/version-6.x/introduction/quick-start.md
  33. +2 −2 website/versioned_docs/version-6.x/introduction/why-use-react-redux.md
  34. +3 −6 website/versioned_docs/version-7.0/introduction/quick-start.md
  35. +2 −2 website/versioned_docs/version-7.0/introduction/why-use-react-redux.md
  36. +99 −42 website/versioned_docs/version-7.1/api/hooks.md
  37. +3 −6 website/versioned_docs/version-7.1/introduction/quick-start.md
  38. +2 −2 website/versioned_docs/version-7.1/introduction/why-use-react-redux.md
  39. +1 −1 website/versioned_docs/version-7.1/using-react-redux/static-types.md
  40. +82 −34 website/versioned_docs/version-7.2/api/hooks.md
  41. +7 −6 website/versioned_docs/version-7.2/introduction/quick-start.md
  42. +2 −2 website/versioned_docs/version-7.2/introduction/why-use-react-redux.md
  43. +1 −1 website/versioned_docs/version-7.2/using-react-redux/static-types.md
  44. +0 −7 website/versions.json
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2
"tabWidth": 2,
"endOfLine": "auto"
}
12 changes: 0 additions & 12 deletions docs/README.md

This file was deleted.

51 changes: 4 additions & 47 deletions docs/api/Provider.md
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@ hide_title: true

## Overview

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

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.
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.

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

### Props

@@ -30,29 +30,12 @@ You may provide a context instance. If you do so, you will need to provide the s
>
> 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.
**Note:** You do not need to provide custom context in order to access the store.
React Redux exports the context instance it uses by default so that you can access the store by:

```js
import { ReactReduxContext } from 'react-redux'

// in your connected component
render() {
return (
<ReactReduxContext.Consumer>
{({ store }) => {
// do something with the store here
}}
</ReactReduxContext.Consumer>
)
}
```


### Example Usage

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

**Vanilla React Example**

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

**Usage with React Router**

```jsx
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { Router, Route } from 'react-router-dom'

import { App } from './App'
import { Foo } from './Foo'
import { Bar } from './Bar'
import createStore from './createReduxStore'

const store = createStore()

ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route exact path="/" component={App} />
<Route path="/foo" component={Foo} />
<Route path="/bar" component={Bar} />
</Router>
</Provider>,
document.getElementById('root')
)
```
2 changes: 2 additions & 0 deletions docs/api/batch.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ hide_title: true
batch((fn: Function))
```

*added in v7.0.0*

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.

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:
7 changes: 6 additions & 1 deletion docs/api/connect-advanced.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,12 @@ It does not modify the component class passed to it; instead, it _returns_ a new
Most applications will not need to use this, as the default behavior in `connect` is intended to work for most use cases.
> Note: `connectAdvanced` was added in version 5.0, and `connect` was reimplemented as a specific set of parameters to `connectAdvanced`.
:::info
`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.
:::
## Arguments
10 changes: 10 additions & 0 deletions docs/api/connect.md
Original file line number Diff line number Diff line change
@@ -577,3 +577,13 @@ const makeMapState = (state) => {
}
export default connect(makeMapState)(SomeComponent)
```
## Legacy Version Docs
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.
For details on the legacy 5.x and 6.x versions, please see these archived files in the React Redux repo:
- [5.x `connect` API reference](https://github.com/reduxjs/react-redux/blob/v7.2.2/website/versioned_docs/version-5.x/api/connect.md)
- [6.x `connect` API reference](https://github.com/reduxjs/react-redux/blob/v7.2.2/website/versioned_docs/version-6.x/api/connect.md)
Loading