mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-26 08:59:01 +02:00
14 lines
318 B
JavaScript
14 lines
318 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) => {
|
|
if (process.browser) {
|
|
return __NEXT_DATA__.props.pageProps;
|
|
}
|
|
|
|
return await callback(props)
|
|
};
|
|
}; |