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
/** | |
* Create a response with a permanently redirect using `301` as status code. | |
*/ | |
export function redirectPermanently( | |
url: string, | |
init?: Omit<ResponseInit, "status"> | |
) { | |
return redirect(url, { ...init, status: 301 }); | |
} |
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
type NextPageWithLayout = NextPage & { | |
getLayout?: (page: ReactElement) => ReactNode; | |
}; | |
type AppPropsWithLayout = AppProps & { | |
Component: NextPageWithLayout; | |
}; | |
export default function MyApp(props: AppPropsWithLayout) { | |
const { Component, pageProps } = props; |
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
export type LooseAutocomplete<T extends string> = T | Omit<string, T>; |
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
import * as React from 'react'; | |
type ErrorBoundaryState = { | |
error?: Error; | |
}; | |
type ErrorBoundaryProps = { | |
children: React.ReactNode; | |
fallback: (state: ErrorBoundaryState) => void; | |
}; |
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
import * as React from 'react'; | |
export const useIsomorphicLayoutEffect = typeof window === 'object' | |
? React.useLayoutEffect | |
: React.useEffect; |
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
/** | |
* Checks if the code is running in the `browser`. | |
*/ | |
export function isBrowser() { | |
return typeof window === 'object'; | |
} | |
/** | |
* Checks if the code is running in the `server`. | |
*/ |
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
import * as React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { useWindowSize } from '@hooks'; | |
function LeftContainer({ children }) { | |
const { width } = useWindowSize(); | |
const isDesktop = width > 1023; | |
return ( | |
<section |
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
import * as React from 'react'; | |
type ErrorBoundaryState = { | |
error?: Error; | |
}; | |
type ErrorBoundaryProps = { | |
children: React.ReactNode; | |
fallback: React.ReactNode | ((state: ErrorBoundaryState) => void); | |
}; |
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
/** | |
* Returns the current object from local storage associated with the given key. | |
* @template T | |
* @param {String} key The key to set in localStorage for this value | |
* @returns {T|undefined} | |
*/ | |
export function getLocalStorageData(key) { | |
const data = window.localStorage.getItem(key); | |
try { | |
return data ? JSON.parse(data) : undefined; |