react报错@react-refresh
报错:Uncaught Error: A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.
原因:suspended=>当网速慢时,指定路由组件页面未加载出,则需使用suspense中的fallback在指定页面出现前,加载fallback中的内容。
解决办法:
<Suspense fallback={<h2>Loading..</h2>}>
<Routes>{renderRoutes(publicRoutes)}</Routes>
</Suspense>