Np. tutaj na filmiku: [...] jest to pokazane. Jako ostatni przykład w filmiku. Tyle, że zapasowy komponent jest wyświetlany w momencie pobierania danych.
Byś otworzył chociaż na sekundę dokumentację Suspense w Reacie i byś się dowiedział: https://beta.reactjs.org/reference/react/Suspense
To jest na prawdę proste, wystarczy:
- Otwórz ulubioną szukajkę, np
google.com
- Wpisz dwa słowa: "React" oraz "Suspense" -> "react suspense"
- Kliknij "Szukaj"
- Kliknij pierwszy link jaki się pojawi
- Czytaj
Cytuję:
Only Suspense-enabled data sources will activate the Suspense component. They include:
- Data fetching with Suspense-enabled frameworks like Relay and Next.js
- Lazy-loading component code with lazy
Suspense does not detect when data is fetched inside an Effect or event handler.
The exact way you would load data in the Albums component above depends on your framework. If you use a Suspense-enabled framework, you’ll find the details in its data fetching documentation.
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
Co do Twojego filmiku, to ja to widze tak, że zobaczyłeś zwykły import i <Suspense/> więc pomyślałeś, że <Susepsnse/> "działa" ze zwykłymi importami. Tylko że w filmiku gość synchronicznie doładował komponenty (czyli u niego też nie działa), ale susepsne się pojawił bo coś w samym załadowanym komponencie doładowuje dodatkowe dane - czyli gość w komponencie użył Susepnse żeby poczekać na dane w komponencie; a Ty próbujesz czekać na sam komponent. Także gość robi jedno, Ty robisz drugie. Zasadność obu jest... no polemizowałbym.
Tak czy tak, mam nadzieję że pomogłem.