- What's a suspense boundary and what it does when throws a promise?
-
import { Suspense } from 'react'; import Albums from './Albums.js'; export default function ArtistPage({ artist }) { return ( <> <h1>{artist.name}</h1> <Suspense fallback={<Loading />}>
-
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 { useState, useRef, useEffect } from "react"; | |
| export function useHover<T extends HTMLElement>() { | |
| const [isHovered, setIsHovered] = useState(false); | |
| const ref = useRef<T | null>(null); | |
| useEffect(() => { | |
| const node = ref.current; | |
| if (!node) return; |
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'; | |
| function App() { | |
| return ( | |
| <ErrorBoundary name="boundary-1"> | |
| <A /> | |
| </ErrorBoundary> | |
| ) |
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 { Suspense } from 'react'; | |
| import Albums from './Albums.js'; | |
| export default function ArtistPage({ artist }) { | |
| return ( | |
| <> | |
| <h1>{artist.name}</h1> | |
| <Suspense fallback={<Loading />}> | |
| <Albums artistId={artist.id} /> | |
| </Suspense> |