reactjs 料用户界面createTheme_default不是函数

ldioqlga  于 2022-12-26  发布在  React
关注(0)|答案(2)|浏览(167)

我用vite和react创建了一个项目。我创建了一个主题来设置我的项目从右到左。一切都很好,项目运行正常。

const theme = createTheme({
  direction: 'rtl' , 
  typography: {
    "fontFamily": `"iransans"`,
    "fontSize": 11,
    "fontWeightLight": 300,
    "fontWeightRegular": 400,
    "fontWeightMedium": 500
   }
})
const cacheRtl = createCache({
  key: "muirtl",
  stylisPlugins: [prefixer, rtlPlugin]
})

function App() {
  let history = useHistory();
  let contained = "Test The";
  return (
    <div className="App">
      <Router>
        <div>
          <Switch>
            <CacheProvider value={cacheRtl}>
              <ThemeProvider theme={theme}>
                <Route exact path="/applicant">
                  <Applicant />
                </Route>
              </ThemeProvider>
            </CacheProvider>
          </Switch>
        </div>
      </Router>
    </div>
  )
}
export default App

在我添加了一个幻灯片组件到我的项目。突然我的项目停止工作,控制台显示
Box.js:5未捕获的类型错误:createTheme_default不是位于Box.js:5:22的函数
我回滚我的修改(通过git检查)。但是错误仍然显示。
我不明白发生了什么事为什么恢复更改后错误仍然存在?

xuo3flqw

xuo3flqw1#

我发现Vite缓存存在问题,请尝试运行带有--force标志的development命令来修复该高速缓存问题:
Yarn变形力
或与国家预防机制合作
npm运行开发-强制

n9vozmp4

n9vozmp42#

我认为这是在index.js中提供的,而不是在App.js中提供的。我们仅在App.js中提供路由,而不是提供程序

相关问题