Powersフェッチ/未定義のときにフォールバック コンポーネントをレンダリングしたい。React.Suspenseコードを使用してロジックに実装しました。
<Suspense fallback={<p>Loading</p>}>
<RoutesPowers />
</Suspense>
そして私のRoutesPowersは
const Powers = [ ... ];
const RoutesPowers = () => {
const [powers, setPowers] = useState(null);
const fetchPowers = () => setTimeout(() => setPowers(Powers), 3000);
useEffect(() => fetchPowers(), []);
return ( powers.map(route => <RoutePowers route={route}/> )
};
しかし、それはCannot read property "map" of nullおそらくpowersnullであるためです。つまり、本来の機能を果たせてReact.Suspenseいないということです。誰でもこれについて私を助けることができますか?