Created
June 12, 2024 13:32
-
-
Save dovranJorayev/d6f5d3179b22fd67e910b5b9997e26ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/next-redux-wrapper/.DS_Store b/node_modules/next-redux-wrapper/.DS_Store | |
new file mode 100644 | |
index 0000000..5008ddf | |
Binary files /dev/null and b/node_modules/next-redux-wrapper/.DS_Store differ | |
diff --git a/node_modules/next-redux-wrapper/es6/index.d.ts b/node_modules/next-redux-wrapper/es6/index.d.ts | |
index 66c1548..181cf6d 100644 | |
--- a/node_modules/next-redux-wrapper/es6/index.d.ts | |
+++ b/node_modules/next-redux-wrapper/es6/index.d.ts | |
@@ -1,6 +1,6 @@ | |
/// <reference types="node" /> | |
/// <reference types="react" /> | |
-import App, { AppContext, AppInitialProps } from 'next/app'; | |
+import App, { AppContext, AppInitialProps, AppProps } from 'next/app'; | |
import { Store } from 'redux'; | |
import { GetServerSideProps, GetServerSidePropsContext, GetStaticProps, GetStaticPropsContext, NextComponentType, NextPageContext } from 'next'; | |
/** | |
@@ -34,9 +34,9 @@ export declare const createWrapper: <S extends Store<any, import("redux").AnyAct | |
displayName: string; | |
getInitialProps: any; | |
}; | |
- useWrappedStore: ({ initialState: giapState, initialProps, ...props }: any, displayName?: string) => { | |
+ useWrappedStore: <P_4 extends AppProps<{}>>(incomingProps: P_4, displayName?: string) => { | |
store: S; | |
- props: any; | |
+ props: P_4; | |
}; | |
}; | |
declare const _default: <S extends Store<any, import("redux").AnyAction>>(makeStore: MakeStore<S>, config?: Config<S>) => (Component: any) => { | |
diff --git a/node_modules/next-redux-wrapper/es6/index.js b/node_modules/next-redux-wrapper/es6/index.js | |
index 6f1a4f1..0989efb 100644 | |
--- a/node_modules/next-redux-wrapper/es6/index.js | |
+++ b/node_modules/next-redux-wrapper/es6/index.js | |
@@ -227,43 +227,68 @@ export var createWrapper = function (makeStore, config) { | |
var useHybridHydrate = function (store, giapState, gspState, gsspState, gippState) { | |
var events = useRouter().events; | |
var shouldHydrate = useRef(true); | |
- // We should only hydrate when the router has changed routes | |
+ /** | |
+ * Moving this functions outside of the useEffect hook | |
+ * to avoid creating new function references on each render. | |
+ */ | |
+ var handleRouteChangeStart = function () { | |
+ shouldHydrate.current = true; | |
+ }; | |
+ var handleRouteChangeComplete = function () { | |
+ shouldHydrate.current = false; | |
+ }; | |
useEffect(function () { | |
- var handleStart = function () { | |
- shouldHydrate.current = true; | |
- }; | |
- events === null || events === void 0 ? void 0 : events.on('routeChangeStart', handleStart); | |
+ events === null || events === void 0 ? void 0 : events.on('routeChangeStart', handleRouteChangeStart); | |
+ /** | |
+ * Depending on whether the user is navigating to a new route or not. | |
+ * This can help avoid unnecessary hydration of components and potentially improve performance. | |
+ * | |
+ * @see https://nextjs.org/docs/api-reference/next/router#routerevents | |
+ */ | |
+ events === null || events === void 0 ? void 0 : events.on('routeChangeComplete', handleRouteChangeComplete); | |
return function () { | |
- events === null || events === void 0 ? void 0 : events.off('routeChangeStart', handleStart); | |
+ events === null || events === void 0 ? void 0 : events.off('routeChangeStart', handleRouteChangeStart); | |
+ events === null || events === void 0 ? void 0 : events.off('routeChangeComplete', handleRouteChangeComplete); | |
}; | |
}, [events]); | |
- // useMemo so that when we navigate client side, we always synchronously hydrate the state before the new page | |
- // components are mounted. This means we hydrate while the previous page components are still mounted. | |
- // You might think that might cause issues because the selectors on the previous page (still mounted) will suddenly | |
- // contain other data, and maybe even nested properties, causing null reference exceptions. | |
- // But that's not the case. | |
- // Hydrating in useMemo will not trigger a rerender of the still mounted page component. So if your selectors do have | |
- // some initial state values causing them to rerun after hydration, and you're accessing deeply nested values inside your | |
- // components, you still wouldn't get errors, because there's no rerender. | |
- // Instead, React will render the new page components straight away, which will have selectors with the correct data. | |
- useMemo(function () { | |
- if (shouldHydrate.current) { | |
- hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
- shouldHydrate.current = false; | |
- } | |
+ var memoizedHydrateOrchestrator = useMemo(function () { | |
+ /** | |
+ * we are returning a function that will be called when the component is unmounted. | |
+ * This function will check if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ */ | |
+ return function () { | |
+ if (shouldHydrate.current) { | |
+ hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
+ } | |
+ }; | |
}, [store, giapState, gspState, gsspState, gippState]); | |
+ useEffect(function () { | |
+ /** | |
+ * This memoizedHydrateOrchestrator function is being created using the useMemo hook to ensure that the function | |
+ * is only created when any of the dependencies passed in the second argument to useMemo changes. | |
+ * | |
+ * This function checks if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ * | |
+ * By memoizing this function, we can ensure that it is only created once and reused on subsequent renders, | |
+ * avoiding unnecessary function calls and potential performance issues. | |
+ */ | |
+ memoizedHydrateOrchestrator(); | |
+ }, [memoizedHydrateOrchestrator]); | |
}; | |
// giapState stands for getInitialAppProps state | |
- var useWrappedStore = function (_a, displayName) { | |
- var _b, _c, _d, _e, _f, _g; | |
+ var useWrappedStore = function (incomingProps, displayName) { | |
+ var _a, _b, _c, _d, _e, _f; | |
if (displayName === void 0) { displayName = 'useWrappedStore'; } | |
- var giapState = _a.initialState, initialProps = _a.initialProps, props = __rest(_a, ["initialState", "initialProps"]); | |
+ // createWrapper adds WrapperProps to incomingProps, they are not present in P so type needs to be coerced here | |
+ var _g = incomingProps, giapState = _g.initialState, initialProps = _g.initialProps, props = __rest(_g, ["initialState", "initialProps"]); | |
// getStaticProps state | |
- var gspState = (props === null || props === void 0 ? void 0 : props.__N_SSG) ? (_b = props === null || props === void 0 ? void 0 : props.pageProps) === null || _b === void 0 ? void 0 : _b.initialState : null; | |
+ var gspState = (props === null || props === void 0 ? void 0 : props.__N_SSG) ? (_a = props === null || props === void 0 ? void 0 : props.pageProps) === null || _a === void 0 ? void 0 : _a.initialState : null; | |
// getServerSideProps state | |
- var gsspState = (props === null || props === void 0 ? void 0 : props.__N_SSP) ? (_c = props === null || props === void 0 ? void 0 : props.pageProps) === null || _c === void 0 ? void 0 : _c.initialState : null; | |
+ var gsspState = (props === null || props === void 0 ? void 0 : props.__N_SSP) ? (_b = props === null || props === void 0 ? void 0 : props.pageProps) === null || _b === void 0 ? void 0 : _b.initialState : null; | |
// getInitialPageProps state | |
- var gippState = !gspState && !gsspState ? (_e = (_d = props === null || props === void 0 ? void 0 : props.pageProps) === null || _d === void 0 ? void 0 : _d.initialState) !== null && _e !== void 0 ? _e : null : null; | |
+ var gippState = !gspState && !gsspState ? (_d = (_c = props === null || props === void 0 ? void 0 : props.pageProps) === null || _c === void 0 ? void 0 : _c.initialState) !== null && _d !== void 0 ? _d : null : null; | |
if (config.debug) { | |
console.log('4.', displayName, 'created new store with', { | |
giapState: giapState, | |
@@ -281,12 +306,12 @@ export var createWrapper = function (makeStore, config) { | |
resultProps.pageProps = __assign(__assign({}, initialProps.pageProps), props.pageProps); | |
} | |
// just some cleanup to prevent passing it as props, we need to clone props to safely delete initialState | |
- if ((_f = props === null || props === void 0 ? void 0 : props.pageProps) === null || _f === void 0 ? void 0 : _f.initialState) { | |
+ if ((_e = props === null || props === void 0 ? void 0 : props.pageProps) === null || _e === void 0 ? void 0 : _e.initialState) { | |
resultProps = __assign(__assign({}, props), { pageProps: __assign({}, props.pageProps) }); | |
delete resultProps.pageProps.initialState; | |
} | |
// unwrap getInitialPageProps | |
- if ((_g = resultProps === null || resultProps === void 0 ? void 0 : resultProps.pageProps) === null || _g === void 0 ? void 0 : _g.initialProps) { | |
+ if ((_f = resultProps === null || resultProps === void 0 ? void 0 : resultProps.pageProps) === null || _f === void 0 ? void 0 : _f.initialProps) { | |
resultProps.pageProps = __assign(__assign({}, resultProps.pageProps), resultProps.pageProps.initialProps); | |
delete resultProps.pageProps.initialProps; | |
} | |
diff --git a/node_modules/next-redux-wrapper/es6/index.js.map b/node_modules/next-redux-wrapper/es6/index.js.map | |
index 0a8df17..9044a65 100644 | |
--- a/node_modules/next-redux-wrapper/es6/index.js.map | |
+++ b/node_modules/next-redux-wrapper/es6/index.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAUrC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,IAAM,OAAO,GAAG,gCAAgC,CAAC;AAExD,IAAM,WAAW,GAAG,cAAM,OAAA,OAAO,MAAM,KAAK,WAAW,EAA7B,CAA6B,CAAC;AAExD,IAAM,oBAAoB,GAAG,UAAkB,YAAiB,EAAE,EAAkC;QAAlC,qBAAgC,EAAE,KAAA,EAAjC,gBAAgB,sBAAA;IAC/E,OAAA,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY;AAAhE,CAAgE,CAAC;AAErE,IAAM,kBAAkB,GAAG,UAAkB,KAAU,EAAE,EAAgC;QAAhC,qBAA8B,EAAE,KAAA,EAA/B,cAAc,oBAAA;IACpE,OAAA,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;AAA9C,CAA8C,CAAC;AASnD,IAAI,iBAAsB,CAAC;AAE3B,IAAM,SAAS,GAAG,UAAkB,EAA8C;;QAA7C,SAAS,eAAA,EAAE,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IACxD,IAAM,WAAW,GAAG,cAAM,OAAA,SAAS,CAAC,OA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E,gBAAgB,CAAC,WAAW,CAAC,EAAnF,KAAK,WAAA,EAAS,aAAa,WAAwD,CAAC;YAE3F,OAAO,CACH,oBAAC,QAAQ,IAAC,KAAK,EAAE,KAAK;gBAClB,oBAAC,SAAS,eAAK,aAAa,EAAI,CACzB,CACd,CAAC;QACN,CAAC,CAAC;QAEF,gBAAgB,CAAC,WAAW,GAAG,oBAAa,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAAW,MAAG,CAAC;QAEtG,IAAI,iBAAiB,IAAI,SAAS,EAAE;YAChC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;SAChE;QAED,OAAO,gBAAgB,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO;QACH,kBAAkB,oBAAA;QAClB,cAAc,gBAAA;QACd,kBAAkB,oBAAA;QAClB,mBAAmB,qBAAA;QACnB,SAAS,WAAA;QACT,eAAe,iBAAA;KAClB,CAAC;AACN,CAAC,CAAC;AAEF,SAAS;AACT,8DAA8D;AAC9D,gBAAe,UAAkB,SAAuB,EAAE,MAAsB;IAAtB,uBAAA,EAAA,WAAsB;IAC5E,OAAO,CAAC,IAAI,CAAC,iHAAiH,CAAC,CAAC;IAChI,OAAO,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC,EAAC"} | |
\ No newline at end of file | |
diff --git a/node_modules/next-redux-wrapper/lib/index.d.ts b/node_modules/next-redux-wrapper/lib/index.d.ts | |
index 66c1548..181cf6d 100644 | |
--- a/node_modules/next-redux-wrapper/lib/index.d.ts | |
+++ b/node_modules/next-redux-wrapper/lib/index.d.ts | |
@@ -1,6 +1,6 @@ | |
/// <reference types="node" /> | |
/// <reference types="react" /> | |
-import App, { AppContext, AppInitialProps } from 'next/app'; | |
+import App, { AppContext, AppInitialProps, AppProps } from 'next/app'; | |
import { Store } from 'redux'; | |
import { GetServerSideProps, GetServerSidePropsContext, GetStaticProps, GetStaticPropsContext, NextComponentType, NextPageContext } from 'next'; | |
/** | |
@@ -34,9 +34,9 @@ export declare const createWrapper: <S extends Store<any, import("redux").AnyAct | |
displayName: string; | |
getInitialProps: any; | |
}; | |
- useWrappedStore: ({ initialState: giapState, initialProps, ...props }: any, displayName?: string) => { | |
+ useWrappedStore: <P_4 extends AppProps<{}>>(incomingProps: P_4, displayName?: string) => { | |
store: S; | |
- props: any; | |
+ props: P_4; | |
}; | |
}; | |
declare const _default: <S extends Store<any, import("redux").AnyAction>>(makeStore: MakeStore<S>, config?: Config<S>) => (Component: any) => { | |
diff --git a/node_modules/next-redux-wrapper/lib/index.js b/node_modules/next-redux-wrapper/lib/index.js | |
index a04f165..38fca09 100644 | |
--- a/node_modules/next-redux-wrapper/lib/index.js | |
+++ b/node_modules/next-redux-wrapper/lib/index.js | |
@@ -249,43 +249,68 @@ var createWrapper = function (makeStore, config) { | |
var useHybridHydrate = function (store, giapState, gspState, gsspState, gippState) { | |
var events = (0, router_1.useRouter)().events; | |
var shouldHydrate = (0, react_1.useRef)(true); | |
- // We should only hydrate when the router has changed routes | |
+ /** | |
+ * Moving this functions outside of the useEffect hook | |
+ * to avoid creating new function references on each render. | |
+ */ | |
+ var handleRouteChangeStart = function () { | |
+ shouldHydrate.current = true; | |
+ }; | |
+ var handleRouteChangeComplete = function () { | |
+ shouldHydrate.current = false; | |
+ }; | |
(0, react_1.useEffect)(function () { | |
- var handleStart = function () { | |
- shouldHydrate.current = true; | |
- }; | |
- events === null || events === void 0 ? void 0 : events.on('routeChangeStart', handleStart); | |
+ events === null || events === void 0 ? void 0 : events.on('routeChangeStart', handleRouteChangeStart); | |
+ /** | |
+ * Depending on whether the user is navigating to a new route or not. | |
+ * This can help avoid unnecessary hydration of components and potentially improve performance. | |
+ * | |
+ * @see https://nextjs.org/docs/api-reference/next/router#routerevents | |
+ */ | |
+ events === null || events === void 0 ? void 0 : events.on('routeChangeComplete', handleRouteChangeComplete); | |
return function () { | |
- events === null || events === void 0 ? void 0 : events.off('routeChangeStart', handleStart); | |
+ events === null || events === void 0 ? void 0 : events.off('routeChangeStart', handleRouteChangeStart); | |
+ events === null || events === void 0 ? void 0 : events.off('routeChangeComplete', handleRouteChangeComplete); | |
}; | |
}, [events]); | |
- // useMemo so that when we navigate client side, we always synchronously hydrate the state before the new page | |
- // components are mounted. This means we hydrate while the previous page components are still mounted. | |
- // You might think that might cause issues because the selectors on the previous page (still mounted) will suddenly | |
- // contain other data, and maybe even nested properties, causing null reference exceptions. | |
- // But that's not the case. | |
- // Hydrating in useMemo will not trigger a rerender of the still mounted page component. So if your selectors do have | |
- // some initial state values causing them to rerun after hydration, and you're accessing deeply nested values inside your | |
- // components, you still wouldn't get errors, because there's no rerender. | |
- // Instead, React will render the new page components straight away, which will have selectors with the correct data. | |
- (0, react_1.useMemo)(function () { | |
- if (shouldHydrate.current) { | |
- hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
- shouldHydrate.current = false; | |
- } | |
+ var memoizedHydrateOrchestrator = (0, react_1.useMemo)(function () { | |
+ /** | |
+ * we are returning a function that will be called when the component is unmounted. | |
+ * This function will check if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ */ | |
+ return function () { | |
+ if (shouldHydrate.current) { | |
+ hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
+ } | |
+ }; | |
}, [store, giapState, gspState, gsspState, gippState]); | |
+ (0, react_1.useEffect)(function () { | |
+ /** | |
+ * This memoizedHydrateOrchestrator function is being created using the useMemo hook to ensure that the function | |
+ * is only created when any of the dependencies passed in the second argument to useMemo changes. | |
+ * | |
+ * This function checks if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ * | |
+ * By memoizing this function, we can ensure that it is only created once and reused on subsequent renders, | |
+ * avoiding unnecessary function calls and potential performance issues. | |
+ */ | |
+ memoizedHydrateOrchestrator(); | |
+ }, [memoizedHydrateOrchestrator]); | |
}; | |
// giapState stands for getInitialAppProps state | |
- var useWrappedStore = function (_a, displayName) { | |
- var _b, _c, _d, _e, _f, _g; | |
+ var useWrappedStore = function (incomingProps, displayName) { | |
+ var _a, _b, _c, _d, _e, _f; | |
if (displayName === void 0) { displayName = 'useWrappedStore'; } | |
- var giapState = _a.initialState, initialProps = _a.initialProps, props = __rest(_a, ["initialState", "initialProps"]); | |
+ // createWrapper adds WrapperProps to incomingProps, they are not present in P so type needs to be coerced here | |
+ var _g = incomingProps, giapState = _g.initialState, initialProps = _g.initialProps, props = __rest(_g, ["initialState", "initialProps"]); | |
// getStaticProps state | |
- var gspState = (props === null || props === void 0 ? void 0 : props.__N_SSG) ? (_b = props === null || props === void 0 ? void 0 : props.pageProps) === null || _b === void 0 ? void 0 : _b.initialState : null; | |
+ var gspState = (props === null || props === void 0 ? void 0 : props.__N_SSG) ? (_a = props === null || props === void 0 ? void 0 : props.pageProps) === null || _a === void 0 ? void 0 : _a.initialState : null; | |
// getServerSideProps state | |
- var gsspState = (props === null || props === void 0 ? void 0 : props.__N_SSP) ? (_c = props === null || props === void 0 ? void 0 : props.pageProps) === null || _c === void 0 ? void 0 : _c.initialState : null; | |
+ var gsspState = (props === null || props === void 0 ? void 0 : props.__N_SSP) ? (_b = props === null || props === void 0 ? void 0 : props.pageProps) === null || _b === void 0 ? void 0 : _b.initialState : null; | |
// getInitialPageProps state | |
- var gippState = !gspState && !gsspState ? (_e = (_d = props === null || props === void 0 ? void 0 : props.pageProps) === null || _d === void 0 ? void 0 : _d.initialState) !== null && _e !== void 0 ? _e : null : null; | |
+ var gippState = !gspState && !gsspState ? (_d = (_c = props === null || props === void 0 ? void 0 : props.pageProps) === null || _c === void 0 ? void 0 : _c.initialState) !== null && _d !== void 0 ? _d : null : null; | |
if (config.debug) { | |
console.log('4.', displayName, 'created new store with', { | |
giapState: giapState, | |
@@ -303,12 +328,12 @@ var createWrapper = function (makeStore, config) { | |
resultProps.pageProps = __assign(__assign({}, initialProps.pageProps), props.pageProps); | |
} | |
// just some cleanup to prevent passing it as props, we need to clone props to safely delete initialState | |
- if ((_f = props === null || props === void 0 ? void 0 : props.pageProps) === null || _f === void 0 ? void 0 : _f.initialState) { | |
+ if ((_e = props === null || props === void 0 ? void 0 : props.pageProps) === null || _e === void 0 ? void 0 : _e.initialState) { | |
resultProps = __assign(__assign({}, props), { pageProps: __assign({}, props.pageProps) }); | |
delete resultProps.pageProps.initialState; | |
} | |
// unwrap getInitialPageProps | |
- if ((_g = resultProps === null || resultProps === void 0 ? void 0 : resultProps.pageProps) === null || _g === void 0 ? void 0 : _g.initialProps) { | |
+ if ((_f = resultProps === null || resultProps === void 0 ? void 0 : resultProps.pageProps) === null || _f === void 0 ? void 0 : _f.initialProps) { | |
resultProps.pageProps = __assign(__assign({}, resultProps.pageProps), resultProps.pageProps.initialProps); | |
delete resultProps.pageProps.initialProps; | |
} | |
diff --git a/node_modules/next-redux-wrapper/lib/index.js.map b/node_modules/next-redux-wrapper/lib/index.js.map | |
index b971f21..9f5626c 100644 | |
--- a/node_modules/next-redux-wrapper/lib/index.js.map | |
+++ b/node_modules/next-redux-wrapper/lib/index.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAwD;AACxD,2CAAqC;AAUrC,sCAAsC;AAEtC;;;;;;;;;;;;;;GAcG;AAEU,QAAA,OAAO,GAAG,gCAAgC,CAAC;AAExD,IAAM,WAAW,GAAG,cAAM,OAAA,OAAO,MAAM,KAAK,WAAW,EAA7B,CAA6B,CAAC;AAExD,IAAM,oBAAoB,GAAG,UAAkB,YAAiB,EAAE,EAAkC;QAAlC,qBAAgC,EAAE,KAAA,EAAjC,gBAAgB,sBAAA;IAC/E,OAAA,gBAAgB,CAAC,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O,IAAA,qBAAa,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC,EAAC"} | |
\ No newline at end of file | |
diff --git a/node_modules/next-redux-wrapper/src/index.tsx b/node_modules/next-redux-wrapper/src/index.tsx | |
index 1adba86..d29912a 100644 | |
--- a/node_modules/next-redux-wrapper/src/index.tsx | |
+++ b/node_modules/next-redux-wrapper/src/index.tsx | |
@@ -1,4 +1,4 @@ | |
-import App, {AppContext, AppInitialProps} from 'next/app'; | |
+import App, {AppContext, AppInitialProps, AppProps} from 'next/app'; | |
import React, {useEffect, useMemo, useRef} from 'react'; | |
import {Provider} from 'react-redux'; | |
import {Store} from 'redux'; | |
@@ -180,41 +180,67 @@ export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, config: | |
const {events} = useRouter(); | |
const shouldHydrate = useRef(true); | |
- // We should only hydrate when the router has changed routes | |
- useEffect(() => { | |
- const handleStart = () => { | |
- shouldHydrate.current = true; | |
- }; | |
+ /** | |
+ * Moving this functions outside of the useEffect hook | |
+ * to avoid creating new function references on each render. | |
+ */ | |
+ const handleRouteChangeStart = () => { | |
+ shouldHydrate.current = true; | |
+ }; | |
+ | |
+ const handleRouteChangeComplete = () => { | |
+ shouldHydrate.current = false; | |
+ }; | |
- events?.on('routeChangeStart', handleStart); | |
+ useEffect(() => { | |
+ events?.on('routeChangeStart', handleRouteChangeStart); | |
+ /** | |
+ * Depending on whether the user is navigating to a new route or not. | |
+ * This can help avoid unnecessary hydration of components and potentially improve performance. | |
+ * | |
+ * @see https://nextjs.org/docs/api-reference/next/router#routerevents | |
+ */ | |
+ events?.on('routeChangeComplete', handleRouteChangeComplete); | |
return () => { | |
- events?.off('routeChangeStart', handleStart); | |
+ events?.off('routeChangeStart', handleRouteChangeStart); | |
+ events?.off('routeChangeComplete', handleRouteChangeComplete); | |
}; | |
}, [events]); | |
- // useMemo so that when we navigate client side, we always synchronously hydrate the state before the new page | |
- // components are mounted. This means we hydrate while the previous page components are still mounted. | |
- // You might think that might cause issues because the selectors on the previous page (still mounted) will suddenly | |
- // contain other data, and maybe even nested properties, causing null reference exceptions. | |
- // But that's not the case. | |
- // Hydrating in useMemo will not trigger a rerender of the still mounted page component. So if your selectors do have | |
- // some initial state values causing them to rerun after hydration, and you're accessing deeply nested values inside your | |
- // components, you still wouldn't get errors, because there's no rerender. | |
- // Instead, React will render the new page components straight away, which will have selectors with the correct data. | |
- useMemo(() => { | |
- if (shouldHydrate.current) { | |
- hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
- shouldHydrate.current = false; | |
- } | |
+ const memoizedHydrateOrchestrator = useMemo(() => { | |
+ /** | |
+ * we are returning a function that will be called when the component is unmounted. | |
+ * This function will check if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ */ | |
+ return () => { | |
+ if (shouldHydrate.current) { | |
+ hydrateOrchestrator(store, giapState, gspState, gsspState, gippState); | |
+ } | |
+ }; | |
}, [store, giapState, gspState, gsspState, gippState]); | |
+ | |
+ useEffect(() => { | |
+ /** | |
+ * This memoizedHydrateOrchestrator function is being created using the useMemo hook to ensure that the function | |
+ * is only created when any of the dependencies passed in the second argument to useMemo changes. | |
+ * | |
+ * This function checks if the shouldHydrate.current flag is true, which means that the router has changed routes, | |
+ * and if it is true, it calls the hydrateOrchestrator function with the necessary states and data. | |
+ * | |
+ * By memoizing this function, we can ensure that it is only created once and reused on subsequent renders, | |
+ * avoiding unnecessary function calls and potential performance issues. | |
+ */ | |
+ memoizedHydrateOrchestrator(); | |
+ }, [memoizedHydrateOrchestrator]); | |
}; | |
// giapState stands for getInitialAppProps state | |
- const useWrappedStore = ( | |
- {initialState: giapState, initialProps, ...props}: any, | |
- displayName = 'useWrappedStore', | |
- ): {store: S; props: any} => { | |
+ const useWrappedStore = <P extends AppProps>(incomingProps: P, displayName = 'useWrappedStore'): {store: S; props: P} => { | |
+ // createWrapper adds WrapperProps to incomingProps, they are not present in P so type needs to be coerced here | |
+ const {initialState: giapState, initialProps, ...props} = incomingProps as P & WrapperProps; | |
+ | |
// getStaticProps state | |
const gspState = props?.__N_SSG ? props?.pageProps?.initialState : null; | |
// getServerSideProps state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment