gatsby-plugin-react-redux
Advanced tools
Comparing version
@@ -5,4 +5,10 @@ # Change Log | ||
<a name="1.0.8"></a> | ||
# [1.0.8](https://github.com/le0nik/gatsby-plugin-react-redux/compare/v1.0.7...v1.0.8) (2019-05-12) | ||
- Remove version ranges from `peerDependencies` | ||
- Simplify `README.md` | ||
<a name="1.0.7"></a> | ||
# [1.0.7](https://github.com/le0nik/gatsby-plugin-react-redux/compare/v1.0.6...v1.0.7) (2019-05-08) | ||
# [1.0.7](https://github.com/le0nik/gatsby-plugin-react-redux/compare/v1.0.6...v1.0.7) (2019-05-12) | ||
@@ -9,0 +15,0 @@ <a name="1.0.6"></a> |
{ | ||
"name": "gatsby-plugin-react-redux", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Gatsby plugin for React-Redux with built-in server-side rendering support", | ||
@@ -25,5 +25,12 @@ "keywords": [ | ||
"license": "MIT", | ||
"dependencies": { | ||
"serialize-javascript": "^1.7.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-redux": "*" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.4", | ||
"@babel/core": "^7.4.5", | ||
"babel-eslint": "^10.0.1", | ||
@@ -33,22 +40,15 @@ "babel-preset-gatsby-package": "^0.1.4", | ||
"eslint": "^5.16.0", | ||
"eslint-config-prettier": "^4.2.0", | ||
"eslint-config-react-app": "^4.0.0", | ||
"eslint-plugin-flowtype": "^3.7.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-config-prettier": "^4.3.0", | ||
"eslint-config-react-app": "^4.0.1", | ||
"eslint-plugin-flowtype": "^3.9.1", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-jsx-a11y": "^6.2.1", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-react": "^7.13.0", | ||
"eslint-plugin-react-hooks": "^1.6.0", | ||
"jest": "^24.8.0", | ||
"prettier": "^1.17.0", | ||
"react": "^16.8.0", | ||
"react-redux": "^7.0.0 || ^7.1.0-alpha.0" | ||
"prettier": "^1.17.1", | ||
"react": "^16.8.6", | ||
"react-redux": "^7.0.3" | ||
}, | ||
"dependencies": { | ||
"serialize-javascript": "^1.7.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0", | ||
"react-redux": "^7.0.0 || ^7.1.0-alpha.0" | ||
}, | ||
"homepage": "https://github.com/le0nik/gatsby-plugin-react-redux/tree/master#readme", | ||
@@ -63,3 +63,7 @@ "repository": "https://github.com/le0nik/gatsby-plugin-react-redux", | ||
] | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0", | ||
"npm": ">=6.0.0" | ||
} | ||
} |
@@ -9,31 +9,8 @@ # gatsby-plugin-react-redux | ||
`npm install --save gatsby-plugin-react-redux` | ||
`npm install --save gatsby-plugin-react-redux react-redux redux` | ||
## What it does | ||
- Wraps your app with redux `Provider` on both client and server | ||
- Securely serializes store state with [serialize-javascript](https://github.com/yahoo/serialize-javascript) on the server and passes it to your `createStore` function on the client | ||
## How to use | ||
**1**. Create module that exports a function which: | ||
- accepts a single argument `preloadedState` | ||
- creates `redux` store passing `preloadedState` as 2nd argument | ||
- returns created store | ||
Example: | ||
`./src/state/createStore.js` | ||
`./gatsby-config.js` | ||
```javascript | ||
import { createStore } from 'redux'; | ||
import reducer from './reducer'; | ||
// For ES5 use `module.exports` | ||
export default preloadedState => { | ||
return createStore(reducer, preloadedState); | ||
}; | ||
``` | ||
**2**. Edit `./gatsby-config.js` | ||
```javascript | ||
module.exports = { | ||
@@ -58,6 +35,20 @@ plugins: [ | ||
}; | ||
``` | ||
``` | ||
`./src/state/createStore.js` // same path you provided in gatsby-config | ||
```javascript | ||
import { createStore } from 'redux'; | ||
function reducer() { | ||
//... | ||
} | ||
// preloadedState will be passed to you by the plugin | ||
export default preloadedState => { | ||
return createStore(reducer, preloadedState); | ||
}; | ||
``` | ||
## License | ||
MIT |
10618
-1.74%53
-14.52%