{"componentChunkName":"component---src-templates-blog-post-js","path":"/react-redux-setup/","result":{"data":{"site":{"siteMetadata":{"title":"Undefined","author":"Anirudh Varma"}},"markdownRemark":{"id":"be88a762-7292-50f0-84cb-8177a4e0efda","excerpt":"Note: This post is not meant to be about the inner workings of React, Redux or\nReact-Router. This is a post detailing my experiences & understanding in\ncreating…","html":"<p><em>Note: This post is not meant to be about the inner workings of React, Redux or\nReact-Router. This is a post detailing my experiences &#x26; understanding in\ncreating an app using all 3 libraries, the problems I faced while doing it &#x26; how\nI got around them.</em></p>\n<p>Some background info on me, professionally I am a backend developer who\nprimarily works with Java. I have worked with <a href=\"https://wicket.apache.org/\">Apache\nWicket</a> for a long time. For those who don’t know\nWicket is a web framework for Java with components at its center. So when I\nwanted to learn a JavaScript frontend library/framework, I chose React as it was\nsimilar to Wicket in terms of creating components and composing them to create\nviews while being lightweight enough that it was easy to learn in isolation.</p>\n<h2 id=\"v1-just-react\" style=\"position:relative;\"><a href=\"#v1-just-react\" aria-label=\"v1 just react permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>V1: Just React</h2>\n<p>To start learning React, I made <a href=\"http://snooplay.surge.sh/\">Snooplay</a>: A media\nplayer for Reddit. The first version of Snooplay was very simple, it just used\nReact, no routing &#x26; no state management. You can checkout the code for v1\n<a href=\"https://github.com/anirudhvarma12/snooplay/tree/v1\">here</a>.</p>\n<h2 id=\"v2-react-meets-router--redux\" style=\"position:relative;\"><a href=\"#v2-react-meets-router--redux\" aria-label=\"v2 react meets router  redux permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>V2: React meets Router &#x26; Redux</h2>\n<p>In order to extend my knowledge to Redux, Middlewares &#x26; React Router, I decided\nto extend Snooplay with the following goals —</p>\n<ul>\n<li>The state for the entire app should be stored &#x26; managed via\n<a href=\"http://redux.js.org/\">Redux</a>.</li>\n<li>The user should be able to change subreddits by altering the URL. eg:\nsnooplay/r/movies. Routing to be handled by\n<a href=\"https://github.com/ReactTraining/react-router\">React-Router.</a></li>\n<li>Create the boiler plate using\n<a href=\"https://github.com/facebookincubator/create-react-app\">create-react-app</a></li>\n<li>All styling should be done via SASS/SCSS and compilation of the same has to be\ndone via Webpack.</li>\n</ul>\n<p>Now that we know, what our goals are, lets get started. Here is some information\non important packages —</p>\n<ul>\n<li>React: v15.6.1</li>\n<li>Redux: v3.7.2</li>\n<li>React-Redux: v5.0.6 (Package that helps connect react components with redux\nstores)</li>\n<li>React-Router: v4.1.2</li>\n<li>Redux-thunk: v2.2.0</li>\n</ul>\n<p>You can checkout the full <a href=\"https://github.com/anirudhvarma12/snooplay/blob/master/package.json\">package.json file\nhere</a>.</p>\n<h3 id=\"step-1-create-the-app-boiler-plate\" style=\"position:relative;\"><a href=\"#step-1-create-the-app-boiler-plate\" aria-label=\"step 1 create the app boiler plate permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 1: Create the app boiler plate.</h3>\n<p>We will create the structure of the app by using Facebook’s create-react-app\n(CRA) tool. After your install CRA, go to your terminal and type the following\ncommand —</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">create-react-app &lt;app_name></code></pre></div>\n<p>create-react-app is a utility that creates a pre-configured project with Webpack\n&#x26; Babel and other tools. This was made to get over the configuration issues that\npeople usually face while wiring up different tools together.</p>\n<p>This process can take some time, once it finishes you can <code class=\"language-text\">cd</code> into the\ndirectory and type <code class=\"language-text\">npm start</code> This would open your browser and you should be\nable to see the React App.</p>\n<p>The entry point for the app is <code class=\"language-text\">index.js</code> which then renders the <code class=\"language-text\">&lt;App /></code>\ncomponent from <code class=\"language-text\">app.js</code> .</p>\n<h3 id=\"step-2-installing-the-libraries\" style=\"position:relative;\"><a href=\"#step-2-installing-the-libraries\" aria-label=\"step 2 installing the libraries permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 2: Installing the libraries</h3>\n<p>Now we need to install our essential libraries i.e. React-Router &#x26; Redux.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">npm install --save redux react-router</code></pre></div>\n<p>Both React-Router &#x26; Redux are very modular libraries. For example, React-Router\ncan also be used in React-Native projects, whereas Redux has no direct\nconnection with React. To make it easy to use these libraries we will install 2\nmore libs.</p>\n<ul>\n<li>react-router-dom: Contains react components to be used in web projects.</li>\n<li>\n<p>react-redux: Helps connect our components with redux, thus making it easy to\nread &#x26; change state from React components.</p>\n<p>  npm install —save react-router-dom react-redux</p>\n</li>\n</ul>\n<h3 id=\"step-3-scss-integration\" style=\"position:relative;\"><a href=\"#step-3-scss-integration\" aria-label=\"step 3 scss integration permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 3: SCSS Integration</h3>\n<p>This step was very tricky, with many resources on the web. Some worked with\nWebpack 1 &#x26; not with Webpack 2 while some refused to work at all.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">npm install --save-dev css-loader extract-text-webpack-plugin node-sass sass-loader</code></pre></div>\n<p>Before we update our webpack configs, we need to *eject *our project. Eject\nbasically means that we will now take care of the webpack &#x26; other config instead\nof just working with what create-react-app gives us. To eject the project just\nrun the following command —</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">npm run eject</code></pre></div>\n<p>After this process is completed, you will find a config folder which would\ncontain 2 webpack files, one is _webpack.config.dev.js _&#x26; other is\n*webpack.config.prod.js. *As you might have guessed, the dev file your\ndevlopment profile (used when you do <code class=\"language-text\">npm start</code> ) and the prod file is your\nproduction profile that performs optimizations before creating a deployment\nbundle (run <code class=\"language-text\">npm run build</code> )</p>\n<p>Now in our <code class=\"language-text\">webpack.config.dev.js</code> we will configure the\n<code class=\"language-text\">extract-text-webpack-plugin</code> to handle the scss files.</p>\n<p><strong>3.1) Get the extract — text plugin in the file.</strong></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const ExtractTextPlugin = require('extract-text-webpack-plugin');</code></pre></div>\n<p>Also declare the CSS file name -</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const cssFilename = 'static/css/[name].[contenthash:8].css';</code></pre></div>\n<p><strong>3.2) Configure rules</strong></p>\n<p>In the <code class=\"language-text\">module.exports</code> object, find the <code class=\"language-text\">module</code> property. In the <code class=\"language-text\">rules</code> array\nyou need to find the following section —</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">// \"oneOf\" will traverse all following loaders until one will                               // match the requirements. When no loader matches it will fall                               // back to the \"file\" loader at the end of the loader list.                               oneOf: [\n....\n]</code></pre></div>\n<p>Here add the config to process <code class=\"language-text\">scss</code> files using appropriate loaders.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">{\ntest: /\\.scss$/,\nuse: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])                                 },</code></pre></div>\n<p><em>Note: Several examples on the internet use the loaders syntax, but that is\ndeprecated.</em></p>\n<p>Also, you should comment out the <code class=\"language-text\">css</code> loader that is pre-configured in the\nfile.</p>\n<h3 id=\"step-4-redux--redux-thunk\" style=\"position:relative;\"><a href=\"#step-4-redux--redux-thunk\" aria-label=\"step 4 redux  redux thunk permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 4: Redux &#x26; Redux-Thunk</h3>\n<p>Before going forward here, I would like to mention 2 resources that helped me\ngreatly in understanding Redux &#x26; Thunks.</p>\n<ol>\n<li>Stephen Grider’s Modern React with Redux course on Udemy. Check it out here —\n<a href=\"https://www.udemy.com/react-redux/\">https://www.udemy.com/react-redux/</a></li>\n<li>Matt Stow’s Dummy’s Guide to Redux &#x26; Thunk. Check it out here-\n<a href=\"https://medium.com/@stowball/a-dummys-guide-to-redux-and-thunk-in-react-d8904a7005d3\">https://medium.com/@stowball/a-dummys-guide-to-redux-and-thunk-in-react-d8904a7005d3</a></li>\n</ol>\n<p>An introduction to the various terms you are going to see moving forward in\nreference to Redux.</p>\n<ul>\n<li>**State: **State refers to the data of the application that we store in Redux.\nRedux creates this one big JavaScript object to store all the state of the\napplication. State can only be updated by Reducers.</li>\n<li>**Reducers: **Reducers are plain JavaScript functions that are responsible for\nupdating the state of the application. Each reducer is responsible for updating\none part of the application state.</li>\n<li><strong>Actions</strong>: An action is basically an object that describes an event that would\nresult in a change in state. Each action has <code class=\"language-text\">type</code> property which helps\nreducers in deciding if they have to respond to this action or not. Function\nthat return actions are called action creators.</li>\n<li>**Redux-Thunk: **Action creators usually returns a plain JavaScript object.\nRedux-Thunk allows you to return functions instead of objects. These functions\nrecieve <code class=\"language-text\">dispatch</code> &#x26; <code class=\"language-text\">getState</code> store functions which allow you to further call\nactions from inside the function. Example of such action creator —</li>\n</ul>\n<p><span class=\"figcaption_hack\">Example of using Redux-Thunk</span></p>\n<h3 id=\"step-5-creating-our-store-and-using-redux\" style=\"position:relative;\"><a href=\"#step-5-creating-our-store-and-using-redux\" aria-label=\"step 5 creating our store and using redux permalink\" class=\"anchor-hint before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 5: Creating our store and using Redux.</h3>\n<p>I would like to outline the process that I used to create my store.</p>\n<ul>\n<li>Design the app state on paper or as a JavaScript object in any text editor.</li>\n<li>Create reducers for each property. At this step all reducers simply returned the\nstate without any other process.</li>\n<li>\n<p>Bind reducer &#x26; properties. This is how the state for Snooplay looks</p>\n<p>//As you can see, each property is assigned a reducer.\nconst rootReducer = combineReducers({ currentPost: ReducerCurrentPost,<br>\nposts: ReducerFetchPosts,\nsubs: ReducerFetchSubreddits,<br>\ncurrentSub: ReducerCurrentSubreddit, loaderVisible: ReducerLoadingState, notification: ReducerNotification, lastPostId: ReducerLastPost\n});</p>\n</li>\n<li>To provide the state to the entire application, you need to wrap your components\nwith <code class=\"language-text\">Provider</code> component provided by <code class=\"language-text\">react-redux</code> package.</li>\n<li>\n<p>Now that we have linked our properties with our reducers, I would like to point\nout that in our reducer functions, <em>the _<code class=\"language-text\">state</code></em> property refers to the value\nof the property only and not the entire state_. For example, here is my\nReducerCurrentPost-</p>\n<p>  // here the state is the value of ‘currentPost’ property of the app // state and not the entire state.\nexport default function currentPostReducer(state = null, action) {</p>\n<p>  }</p>\n</li>\n<li>\n<p>**Actions &#x26; Action Creators. **As described earlier the action is simply a JS\nobject with a type field. Any data that has to be sent to the reducer can be\nsent as the payload property of the action. Here is what the action creator to\nset the current post look like-</p>\n<p>  //This is an action creator, returns an action with a type and //payload.\nexport const setCurrentPost = (post) => {\nreturn {\ntype: ACTION<em>CURRENT</em>POST,\npayload: post\n}\n}</p>\n</li>\n</ul>\n<p>When this action is dispatched (called) like <code class=\"language-text\">setCurrentPost(post)</code> redux sends\nthis action to all reducers. The the current post reducer can respond like-</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import { ACTION_CURRENT_POST } from './../Constants';\n\nexport default function currentPostReducer(state = null, action) {\n    switch (action.type) {\n    //This reducer checks the current action type\n    //Returns the post (payload)\n    //This post is updated in the state\n      case ACTION_CURRENT_POST: {\n        return action.payload\n      }\n      default: {\n        return state;\n      }\n    }\n}</code></pre></div>\n<p>Next, we want our components to update when the associated state is changed. So\nlets say we have a component which displays the current post. When the reducer\nupdates the current post in the state, we want this component to re-render to\nshow the new post. This is where the <code class=\"language-text\">connect</code> method from the <code class=\"language-text\">react-redux</code>\nlibrary comes into play. It connects the react components with its associated\nstate.</p>\n<p><em>Note: In react world, components which work directly with the store are called\nContainer Components and components which work only on the given props\n(irrespective of where the props are supplied from) are called Presentation\nComponents.</em></p>\n<p>This is what my PostContainer component looks like. It is directly connected to\nthe store —</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import React, { Component } from 'react';\nimport { connect } from 'react-redux';\nimport { bindActionCreators } from 'redux';\nimport { setCurrentPost } from './../../actions/';\n\nclass PostContainer extends Component {\n    render(){\n       return(&lt;h1>{this.props.post.title}&lt;/h1>)\n   }\n}\n\nfunction mapStateToProps(state){\n    return {\n      post: state.currentPost\n    }\n}\n\nfunction mapDispatchToProps(dispatch){\n    return {\n      actions:{\n        closePlayer: bindActionCreators(setCurrentPost, dispatch)\n      }\n    }\n}\n\nexport default connect(mapStateToProps, mapDispatchToProps)PostContainer);</code></pre></div>\n<p>So whats happening here?</p>\n<p>Here we create a Component that has to render some details about the current\npost of the application.</p>\n<ul>\n<li><code class=\"language-text\">mapStateToProps</code> is responsible for taking the entire application state and\nthen getting out the relevant pieces needed to render the current component.\nThese pieces are then provided to the components as <code class=\"language-text\">props</code> <br> In the above\nexample the <code class=\"language-text\">currentPost</code> property of the application state is accessed using\nthe standard props mechanism.</li>\n<li><code class=\"language-text\">mapDispatchToProps</code> is used to call actions from inside the component. In the\nabove example, I use the <code class=\"language-text\">setCurrentPost</code>action to close the player. you can\ncall the <code class=\"language-text\">setCurrentPost</code> action by calling\n<code class=\"language-text\">this.props.actions.closePlayer(null)</code> .</li>\n<li>In the end we use <code class=\"language-text\">connect</code>to wire all these together. Now whenever the\n<code class=\"language-text\">currentPost</code> property is updated in the state, <code class=\"language-text\">PostContainer</code> will be updated\nto reflect this change.</li>\n</ul>\n<p><em>Note: if you are wondering why to use mapDispatchToProps — Read</em> <a href=\"https://stackoverflow.com/a/41782298/1563269\">this\nStackOverflow answer</a></p>\n<p>After this you can setup React-Router. There are many great examples/guides on\nhow to do this. Just note that do not follow a react-router v3 guide if you are\nworking with v4 as v4 is a complete re-write.</p>\n<p>React Router setup was a breeze, one thing that bugged me was navigating to\npaths programmatically. To do this in v4, I have used the <code class=\"language-text\">withRouter</code> Component\nfrom <code class=\"language-text\">react-router-dom</code> package. This is what it looks like —</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import React, { Component } from 'react';\nimport { withRouter } from 'react-router-dom'\n\nclass SubmitLink extends Component {\n\n    handleClick = () => {\n      if (this.props.onClick()) {\n        this.props.history.push(this.props.navigateTo());\n      }\n    }\n\n    render() {\n      return (\n       &lt;a onClick={this.handleClick} className=\"button\">   {this.props.label}&lt;/a>)\n      }\n    }\n}\n\nconst NavigableSubmitLink = withRouter(SubmitLink);\n\nexport default NavigableSubmitLink;</code></pre></div>\n<p>This component first calls the <code class=\"language-text\">onClick</code> property, if that function returns\ntrue, then it calls the <code class=\"language-text\">navigateTo</code> function which returns the new path that it\nhas to go to after computation. Using <code class=\"language-text\">withRouter</code> gives us access to updated\n<code class=\"language-text\">match</code>, <code class=\"language-text\">location</code>, and <code class=\"language-text\">history</code> props.</p>\n<p>Ending Notes —</p>\n<ul>\n<li><strong>The real documentation is in the issues:</strong> In the Java world, we have Java\nDocs &#x26; where they don’t help StackOverflow steps in. But in the JS world, most\nproblems I ran into were solved somewhere in GitHub issues. <em>So if you run into\nproblems, don’t skip the GitHub issues.</em></li>\n<li>In the Udemy course linked above, they use <strong>react-promise</strong> middleware, but\nhere I use <strong>react-thunk</strong> middleware even for Ajax calls. That’s just a\npersonal preference because I prefer less magic in my code :)</li>\n</ul>\n<p>That’s the end of this article, I have tried to explain all the problems I faced\nand how I overcome them. If you want to more detailed explanations of React,\nRedux &#x26; Redux-Thunk, look at the resources I have linked above.</p>","frontmatter":{"title":"Dev Diary: My React, Redux & React Router Setup.","date":"August 23, 2017","ogimage":null}}},"pageContext":{"slug":"/react-redux-setup/","previous":{"fields":{"slug":"/in-search-of-code-buddy/"},"frontmatter":{"title":"In Search of a Code Buddy - Adventures of a lonely programmer"}},"next":{"fields":{"slug":"/bolt-content-and-relations/"},"frontmatter":{"title":"Bolt CMS: Using content types and relations"}}}},"staticQueryHashes":["426816048","983108779"]}