前言
我通过 vite 构建了一个 react 应用并使用 react.lazy 来懒加载组件,但是在使用过程中 一直提示 Fast refresh only works when a file only exports components. Move your component(s) to a separate file.eslint(react-refresh/only-export-components)。这里简单的记录下问题的修复方式。
复现方式
先定义一组路由并导出
// src/router/index.jsx
import {
lazy } from "react"
import {
Navigate } from "react-router-dom"
const Home = lazy(() => import("../views/home"))
const routes = [
{
path: "/", element: <Navigate to="/home" /> },
{
path: "/home", element: <Home /

最低0.47元/天 解锁文章
894

被折叠的 条评论
为什么被折叠?



