From e7a367b2a3e4197ea8f1b3e757ef25976f908c58 Mon Sep 17 00:00:00 2001 From: maecapozzi Date: Fri, 7 Sep 2018 21:05:46 -0400 Subject: [PATCH 1/3] Add updated Provider docs --- docs/api/Provider.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/api/Provider.md diff --git a/docs/api/Provider.md b/docs/api/Provider.md new file mode 100644 index 000000000..e69de29bb From 1c302c629f18bc20856c356623d9c3676fe7e853 Mon Sep 17 00:00:00 2001 From: maecapozzi Date: Fri, 7 Sep 2018 21:16:04 -0400 Subject: [PATCH 2/3] Add Provider documentation --- docs/api/Provider.md | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/docs/api/Provider.md b/docs/api/Provider.md index e69de29bb..6a4c8f193 100644 --- a/docs/api/Provider.md +++ b/docs/api/Provider.md @@ -0,0 +1,75 @@ +# `` + +## Overview + +The `` makes the Redux `store` available to any nested components that have been wrapped in the `connect()` function. + +Since any React component in a React-Redux app can be connected, most applications will render a `` 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 `` . + +Note: If you really need to, you can manually pass `store` as a prop to a connected component, but we only recommend to do this for stubbing `store` in unit tests, or in non-fully-React codebases. Normally, you should just use ``. + +### Props + +`store` (Redux Store) +The single Redux `store` in your application. + +`children` (ReactElement) +The root of your component hierarchy. + + +### Example Usage + +In the example below, the `` component is our root-level component. This means it’s at the very top of our component hierarchy. + +Vanilla React Example + + + import React from 'react'; + import ReactDOM from 'react-dom'; + import { Provider } from 'react-redux'; + + import { App } from './App'; + import createStore from './createReduxStore'; + + const store = createStore(); + + ReactDOM.render( + + + , + document.getElementById('root') + ) + + + +Usage with React Router + + + 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( + + + + + + + + , + document.getElementById('root') + ) + + + From 05bd444aa0c122bd28d48c60762fb3acec45aa85 Mon Sep 17 00:00:00 2001 From: maecapozzi Date: Fri, 7 Sep 2018 21:18:02 -0400 Subject: [PATCH 3/3] Update formatting --- docs/api/Provider.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/Provider.md b/docs/api/Provider.md index 6a4c8f193..2d14a6dab 100644 --- a/docs/api/Provider.md +++ b/docs/api/Provider.md @@ -23,9 +23,9 @@ The root of your component hierarchy. In the example below, the `` component is our root-level component. This means it’s at the very top of our component hierarchy. -Vanilla React Example - +**Vanilla React Example** +```js import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; @@ -41,12 +41,12 @@ Vanilla React Example , document.getElementById('root') ) - +``` -Usage with React Router - +**Usage with React Router** +```js import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; @@ -70,6 +70,6 @@ Usage with React Router , document.getElementById('root') ) - +```