2019-10-31 00:54:53 +04:00
|
|
|
/**
|
|
|
|
* 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) => {
|
|
|
|
if (process.browser) {
|
2019-11-06 18:20:09 +04:00
|
|
|
// noinspection ES6ModulesDependencies,JSUnresolvedVariable
|
2019-10-31 00:54:53 +04:00
|
|
|
return __NEXT_DATA__.props.pageProps;
|
|
|
|
}
|
|
|
|
|
|
|
|
return await callback(props)
|
|
|
|
};
|
2019-11-06 18:20:09 +04:00
|
|
|
};
|