Answers for "use redux in gatsby"

1

use redux in gatsby

npm install --save gatsby-plugin-react-redux react-redux redux

// 
yarn add gatsby-plugin-react-redux react-redux redux

// How to use
// same path you provided in gatsby-config
// ./src/state/createStore.js 

import { createStore } from 'redux';

function reducer() {
  //...
}

// preloadedState will be passed in by the plugin
export default preloadedState => {
  return createStore(reducer, preloadedState);
};
Posted by: Guest on July-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language