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
| /** hooks/useRefresh.ts */ | |
| const useRefresh = () => { | |
| const [, dispatch] = useReducer((bool) => !bool, true); | |
| return dispatch; | |
| }; | |
| /** hooks/useInit.ts */ | |
| const useInit = (fn: () => any) => { | |
| const initialized = useRef(false); | |
| if (!initialized.current) { |
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
| function getRandom() { | |
| return fetch("https://api.quotable.io/random").then((response) => { | |
| if (!response.ok) { | |
| throw new Error("Failed to fetch quote"); | |
| } | |
| return response.json(); | |
| }); | |
| } | |
| let initialized = false; |
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
| function QuoteOfTheDay() { | |
| const [quote, setQuote] = useState(""); | |
| const [isLoading, setIsLoading] = useState(true); | |
| const [error, setError] = useState(null); | |
| useEffect(() => { | |
| fetch("https://api.quotable.io/random") | |
| .then((response) => { | |
| if (!response.ok) { | |
| throw new Error("Failed to fetch quote"); |
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
| interface ANarrowProps { | |
| children: string; | |
| } | |
| interface BNarrowProps { | |
| childNodes: string; | |
| } | |
| export const ANarrow = ({ children }: ANarrowProps) => { | |
| return <section>{children}</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
| interface AProps extends React.PropsWithChildren {} | |
| interface BProps { | |
| childNodes?: React.ReactNode | undefined; | |
| } | |
| export const A = ({ children }: AProps) => { | |
| return <section>{children}</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 Image, { type ImageProps } from 'next/image'; | |
| interface AvatarProps extends ImageProps { | |
| imageUrl: string; | |
| altText: string; | |
| } | |
| export const Avatar: React.FunctionComponent<AvatarProps> = ({ | |
| imageUrl, | |
| altText, |
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 Image, { type ImageProps } from 'next/image'; | |
| import { type User } from './types'; | |
| interface UserAvatarProps extends ImageProps { | |
| user: User; | |
| } | |
| export const UserAvatar: React.FunctionComponent<UserAvatarProps> = ({ | |
| user, |
NewerOlder