-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs/refactor getting started (#1054)
* Refactor docs to contain a quick start and move getting started to "basic tutorial" * Follow up doc site updates
- Loading branch information
1 parent
ba6b010
commit 0d9325e
Showing
7 changed files
with
124 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
id: quick-start | ||
title: Quick Start | ||
hide_title: true | ||
sidebar_label: Quick Start | ||
--- | ||
|
||
# Quick Start | ||
|
||
[React-Redux](https://github.com/reduxjs/react-redux) is the official [React](https://reactjs.org/) binding 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 data. | ||
|
||
## Installation | ||
|
||
To use React-Redux with your React app: | ||
|
||
```bash | ||
npm install --save react-redux | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
yarn add react-redux | ||
``` | ||
|
||
## `Provider` and `connect` | ||
|
||
React-Redux provides `<Provider />`, which makes the Redux store available to the rest of your app: | ||
|
||
```js | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
import { Provider } from "react-redux"; | ||
import store from "./store"; | ||
|
||
import App from "./App"; | ||
|
||
const rootElement = document.getElementById("root"); | ||
ReactDOM.render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
rootElement | ||
); | ||
``` | ||
|
||
React-Redux provides a `connect` function for you to connect your component to the store. | ||
|
||
Normally, you’ll call `connect` in this way: | ||
|
||
```js | ||
import { connect } from "react-redux"; | ||
import { increment, decrement, reset } from "./actionCreators"; | ||
|
||
// const Counter = ... | ||
|
||
const mapStateToProps = (state /*, ownProps*/) => { | ||
return { | ||
counter: state.counter | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = { increment, decrement, reset }; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Counter); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters