{"id":370726,"date":"2023-03-01T12:03:16","date_gmt":"2023-03-01T12:03:16","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=370726"},"modified":"2023-03-29T04:14:17","modified_gmt":"2023-03-29T04:14:17","slug":"react-code-splitting-with-redux-redux-saga","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/","title":{"rendered":"React code splitting with redux &amp; redux saga"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">React code splitting<\/h2>\n\n\n\n<p>React code splitting is a technique for optimizing the performance of React applications by splitting the application code into smaller chunks, which can be loaded on demand as needed. <\/p>\n\n\n\n<p>This helps to reduce the initial load time of the application, so this  improve its overall performance, and enhance the user experience.<\/p>\n\n\n\n<p>React code splitting can be achieved in a number of ways, depending on the specific needs of the application. One popular approach is to use dynamic imports, which allow components or modules to be loaded on demand, rather than all at once. <\/p>\n\n\n\n<p>This can be achieved using tools like Webpack or Rollup, which support code splitting by generating multiple output files, each containing a subset of the application code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> <\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>React code splitting is well documented by react official <\/strong><\/p>\n<cite>You can visit and use react code splitting, before implementing redux &amp; redux saga code splitting,<br>Visit the following link : <strong><a href=\"https:\/\/reactjs.org\/docs\/code-splitting.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/reactjs.org\/docs\/code-splitting.html<\/a><\/strong> <\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity is-style-wide\" \/>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">Redux code splitting<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Install dependencies<\/h2>\n\n\n\n<p>we are using here all the latest packages, so we need the following dependencies for setting up the redux and redux Saga. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. React redux<\/h3>\n\n\n\n<p><strong><a href=\"https:\/\/react-redux.js.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">React Redux<\/a>&nbsp;<\/strong>is the official&nbsp;react&nbsp;UI bindings layer for&nbsp;redux. It lets your React components read data from a redux store, and dispatch actions to the store to update state.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install react-redux<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Redux toolkit<\/h3>\n\n\n\n<p>The&nbsp;<strong><a href=\"https:\/\/redux-toolkit.js.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Redux Toolkit<\/a><\/strong>&nbsp;package is intended to be the standard way to write&nbsp;<a href=\"https:\/\/redux.js.org\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Redux<\/strong><\/a>&nbsp;logic. It was originally created to help address two common concerns about Redux:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Configuring a Redux store is too complicated<\/li>\n\n\n\n<li>Redux requires too much boilerplate code<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install @reduxjs\/toolkit<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Redux Saga<\/h2>\n\n\n\n<p><code><strong><a href=\"https:\/\/redux-saga.js.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Redux-Saga<\/a><\/strong><\/code>&nbsp;is a library that aims to make application side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) easier to manage, more efficient to execute, easy to test, and better at handling failures.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install redux-saga<\/pre>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Setup redux store<\/h3>\n\n\n\n<p>The redux store is a key concept in the redux library, which is a state management library for JavaScript applications.<\/p>\n\n\n\n<p> The store is a centralized object that holds the entire state of the application, and serves as a single source of truth for all the data in the application.<\/p>\n\n\n\n<p>create the file <strong>store.js <\/strong>and write following code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\nimport { configureStore } from &quot;@reduxjs\/toolkit&quot;;\nimport { setupListeners } from &quot;@reduxjs\/toolkit\/query&quot;;\nimport createSagaMiddleware from &quot;redux-saga&quot;;\nimport {createSagaInjector, rootSaga} from &quot;.\/sagas&quot;;\nimport createReducer from &quot;.\/reducers&quot;;\n\n    const sagaMiddleware = createSagaMiddleware();\n    const store = configureStore({\n        reducer: createReducer(),\n        middleware: (gdm) =&gt; &#091;...gdm({ serializableCheck: false }).concat(&#091;sagaMiddleware])]\n    });\n\n    store.injectSaga = createSagaInjector(sagaMiddleware.run, rootSaga);\n    store.asyncReducers = {};\n    store.injectReducer = (key, asyncReducer) =&gt; {\n        store.asyncReducers&#091;key] = asyncReducer;\n        store.replaceReducer(createReducer(store.asyncReducers));\n    };\nsetupListeners(store.dispatch);\nexport default store;<\/pre>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<div style=\"height:32px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Create reducers<\/h3>\n\n\n\n<p>Here we used redux <strong>combineReducers<\/strong>  function, for combining static reducers and asynchronous reducers.  we created a function <strong>createReducer<\/strong> and we used this in to our<strong> store.js <\/strong>file.<\/p>\n\n\n\n<p>create a reducers directory and <strong>index.js<\/strong> file then write the following code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import { combineReducers } from &#039;redux&#039;;\n\nimport headerReducer from &quot;.\/header&quot;;\n\nconst staticReducers = {\n        theme: headerReducer,\n};\nconst createReducer =  (asyncReducers) =&gt; {\n    return combineReducers({\n    ...staticReducers,\n    ...asyncReducers,\n    });\n}\n\nexport default createReducer;<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Create header reducer using Redux toolkit &#8211; <\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">import { createSlice } from &quot;@reduxjs\/toolkit&quot;;\n\n\nconst headerSlice = createSlice({\n    name: &quot;theme&quot;,\n    initialState: {\n            mode: &#039;light&#039;,\n            loading: false,\n            error:&#039;&#039;,\n        },\n    reducers: {\n        switchThemeMode: (state) =&gt; {\n            state.loading = true;\n        },\n        setThemeMode: (state, action) =&gt; {\n            state.loading = false;\n            state.mode =  action.payload;\n        },\n        setFailure: (state, action) =&gt; {\n            state.loading = false;\n            state.error =  action.payload;\n        }\n    }\n});\n\nexport const { setThemeMode, switchThemeMode, setFailure } = headerSlice.actions;\nexport default headerSlice.reducer;<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Redux Toolkit <\/strong><\/p>\n<cite><strong>Redux Toolkit <\/strong>is a library that simplifies the process of creating Redux stores and reduces the amount of boilerplate code needed.<br><br>It provides a set of utilities, including a <strong>createSlice() <\/strong>function, so that helps to streamline the process of creating Redux reducers.<br><br>The <strong>createSlice() <\/strong>function generates a slice of Redux state that includes a reducer function, action creators, and action types, all based on a set of input parameters.<\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Create Sagas<\/h3>\n\n\n\n<p>let&#8217;s create a saga <strong>createSagaInjector<\/strong> function for injecting sagas, and <strong>rootSaga<\/strong> function as this is needed in our saga injector,  and we have used both of these functions in our <strong>store.js<\/strong> file.<\/p>\n\n\n\n<p>create a sagas directory and <strong>index.js<\/strong> file then write the following code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import { all } from &#039;redux-saga\/effects&#039;;\n\nexport  function* rootSaga() {\n    yield all(&#091;]);\n}\n\nexport const createSagaInjector = (runSaga, rootSaga) =&gt; {\n    const injectedSagas = new Map();\n    const isInjected = key =&gt; injectedSagas.has(key);\n    const injectSaga = (key, saga) =&gt; {\n        if (isInjected(key)) return;\n        const task = runSaga(saga);\n        injectedSagas.set(key, task);\n    };\n    injectSaga(&#039;root&#039;, rootSaga);\n    return injectSaga;\n}<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Create header saga using Redux Saga &#8211; <\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\">import { put, takeEvery } from &#039;redux-saga\/effects&#039;;\nimport { setThemeMode, setFailure } from &quot;.\/reducers\/header&quot;;\n\nfunction* setThemeSaga({ payload }) {\n    let mode = payload;\n    try {\n        const isOsDark = window.matchMedia(&#039;(prefers-color-scheme: dark)&#039;).matches;\n        const osMode = (isOsDark) ? &#039;dark&#039; : &#039;light&#039;;\n        const isModeExist = (&#039;theme&#039; in localStorage);\n\n        mode = (isModeExist) ? ((!!mode) ? mode : localStorage.theme) : ((!!mode) ? mode : osMode);\n\n        if (mode === &#039;light&#039;) {\n            document.documentElement.classList.remove(&#039;dark&#039;);\n            document.documentElement.classList.add(&#039;light&#039;);\n            localStorage.setItem(&#039;theme&#039;, &#039;light&#039;);\n        } else {\n            document.documentElement.classList.remove(&#039;light&#039;);\n            document.documentElement.classList.add(&#039;dark&#039;);\n            localStorage.setItem(&#039;theme&#039;, &#039;dark&#039;);\n        }\n\n        yield put(setThemeMode(mode));\n        } catch (error) {\n            yield put(setFailure(error));\n\n        }\n    }\n\nexport function* switchThemeSaga() {\n    yield takeEvery(&#039;theme\/switchThemeMode&#039;, setThemeSaga);\n}<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Redux Saga<\/strong><\/p>\n<cite>Redux Saga is a middleware library for Redux that helps manage asynchronous side effects in an application, such as API requests or other I\/O operations. It provides a way to handle side effects in a declarative and testable way, by using generator functions. <br><br>With Redux Saga, side effects are represented as generator functions called &#8220;sagas&#8221;. A saga is a function that can listen for specific actions dispatched to the Redux store, and then perform some asynchronous operation or other side effect. <\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Create Header component<\/h2>\n\n\n\n<p>Create a header component for call the theme switch functionality &#8211; <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">import { Fragment } from &#039;react&#039;;\nimport { useDispatch, useSelector } from &#039;react-redux&#039;;\n\nimport store from &#039;.\/store&#039;;\nimport { switchThemeSaga } from &quot;.\/sagas\/header&quot;;\nimport { switchThemeMode } from &#039;.\/reducers\/header&#039;;\n\nstore.injectSaga(&#039;switchThemeSaga&#039;, switchThemeSaga);\n\nconst Header = () =&gt; {\n    const dispatch = useDispatch();\n    const { mode } = useSelector(state =&gt; state.theme);\n\n    const handleThemeMode = () =&gt; {\n        dispatch(switchThemeMode((mode === &#039;dark&#039;) ? &#039;light&#039; : &#039;dark&#039;));\n    }\n\n    return (\n        &lt;Fragment&gt;\n          &lt;button type=&quot;button&quot; onClick={handleThemeMode}&gt;Switch Theme Mode&lt;\/button&gt;\n        &lt;\/Fragment&gt;\n    )\n\n};\n\nexport default Header;<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/* You can inject other reducers by the following code *\/\n\n\/* import accountReducer from &#039;.\/reducers\/account&#039;; *\/\n\n\/* store.injectReducer(&#039;account&#039;, accountReducer); *\/<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Congrats! now redux and sagas are splatted, create your reducers and sagas and inject them before creating any component, so the code of the redux and sagas will split in to the components chunks as the react split the components in chunks. <\/p>\n\n\n\n<p>This will make heavy main build file, which helps to load the app faster even if there 100s of reducers an sagas are created.<\/p>\n\n\n\n<p>here is the example of injecting reducers and sagas &#8211;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\nimport store from &#039;.\/redux\/store&#039;;\nimport cartReducer, { getCart } from &quot;.\/redux\/reducers\/cart&quot;;\nimport orderReducer, { createOrder } from &quot;.\/redux\/reducers\/orders&quot;;\nimport paymentGatewaysReducer, { getPaymentGateways } from &quot;.\/redux\/reducers\/payments&quot;;\nimport { getCartSaga, emptyCartSaga } from &quot;.\/redux\/sagas\/cart&quot;;\nimport { getPaymentGatewaysSaga } from &quot;.\/redux\/sagas\/payments&quot;;\nimport { createOrderSaga } from &quot;.\/redux\/sagas\/orders&quot;;\n\n\nstore.injectReducer(&#039;cart&#039;, cartReducer);\nstore.injectReducer(&#039;payments&#039;, paymentGatewaysReducer);\nstore.injectReducer(&#039;orders&#039;, orderReducer);\nstore.injectSaga(&#039;getCartSaga&#039;, getCartSaga);\nstore.injectSaga(&#039;getPaymentGatewaysSaga&#039;, getPaymentGatewaysSaga);\nstore.injectSaga(&#039;createOrderSaga&#039;, createOrderSaga);\nstore.injectSaga(&#039;emptyCartSaga&#039;, emptyCartSaga);<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Thanks for reading the article.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>React code splitting React code splitting is a technique for optimizing the performance of React applications by splitting the application code into smaller chunks, which can be loaded on demand as needed. This helps to reduce the initial load time of the application, so this improve its overall performance, and enhance the user experience. React <a href=\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":514,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6357,1],"tags":[],"class_list":["post-370726","post","type-post","status-publish","format-standard","hentry","category-react-js","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React code splitting with redux &amp; redux saga - Webkul Blog<\/title>\n<meta name=\"description\" content=\"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React code splitting with redux &amp; redux saga - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-01T12:03:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-29T04:14:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajeet Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajeet Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\"},\"author\":{\"name\":\"Ajeet Kumar\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5f808ce65cf4b6793c84e4194fcbb50a\"},\"headline\":\"React code splitting with redux &amp; redux saga\",\"datePublished\":\"2023-03-01T12:03:16+00:00\",\"dateModified\":\"2023-03-29T04:14:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\"},\"wordCount\":735,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"react js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\",\"url\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\",\"name\":\"React code splitting with redux &amp; redux saga - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2023-03-01T12:03:16+00:00\",\"dateModified\":\"2023-03-29T04:14:17+00:00\",\"description\":\"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React code splitting with redux and redux saga\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5f808ce65cf4b6793c84e4194fcbb50a\",\"name\":\"Ajeet Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b53b8b6a4395f59f9d903094cded9b2544da27386e70990e16b993e658c17f4b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b53b8b6a4395f59f9d903094cded9b2544da27386e70990e16b993e658c17f4b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ajeet Kumar\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/ajeetkumar-wp300\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React code splitting with redux &amp; redux saga - Webkul Blog","description":"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/","og_locale":"en_US","og_type":"article","og_title":"React code splitting with redux &amp; redux saga - Webkul Blog","og_description":"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.","og_url":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-03-01T12:03:16+00:00","article_modified_time":"2023-03-29T04:14:17+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Ajeet Kumar","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ajeet Kumar","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/"},"author":{"name":"Ajeet Kumar","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5f808ce65cf4b6793c84e4194fcbb50a"},"headline":"React code splitting with redux &amp; redux saga","datePublished":"2023-03-01T12:03:16+00:00","dateModified":"2023-03-29T04:14:17+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/"},"wordCount":735,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["react js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/","url":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/","name":"React code splitting with redux &amp; redux saga - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2023-03-01T12:03:16+00:00","dateModified":"2023-03-29T04:14:17+00:00","description":"React code splitting with redux &amp; redux saga is a technique for optimizing the performance of a React Redux application by splitting the code into smaller, more manageable chunks that can be loaded on-demand as needed. Code splitting can help reduce the initial load time of the application and improve its overall performance by only loading the code that is needed at a given time.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/react-code-splitting-with-redux-redux-saga\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"React code splitting with redux and redux saga"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5f808ce65cf4b6793c84e4194fcbb50a","name":"Ajeet Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b53b8b6a4395f59f9d903094cded9b2544da27386e70990e16b993e658c17f4b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b53b8b6a4395f59f9d903094cded9b2544da27386e70990e16b993e658c17f4b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ajeet Kumar"},"url":"https:\/\/webkul.com\/blog\/author\/ajeetkumar-wp300\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/370726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/514"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=370726"}],"version-history":[{"count":19,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/370726\/revisions"}],"predecessor-version":[{"id":371122,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/370726\/revisions\/371122"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=370726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=370726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=370726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}