1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-24 19:42:51 +01:00
2020-01-17 19:18:47 +04:00

17 lines
426 B
JavaScript

/**
* Makes sure that the props are fetched only on server and not in browser
* @param callback
* @returns {Function}
*/
export const serverOnlyProps = (callback) => {
return async (props) => {
// noinspection JSUnresolvedVariable
if (process.browser) {
// noinspection ES6ModulesDependencies,JSUnresolvedVariable
return __NEXT_DATA__.props.pageProps;
}
return await callback(props)
};
};