You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Material UI AppBar组件时遇到react中不存在useInsertionEffect(导入为useInsertionEffect$1)的错误

Fixing "useInsertionEffect not found in 'react'" Error with Material UI AppBar

Hey there! That error you're hitting with the Material UI AppBar component boils down to a version mismatch between React and Material UI (MUI). Let me break it down and walk you through the fixes:

The useInsertionEffect hook was introduced in React 18. If your project is running an older React version (like 17 or below), newer MUI releases (v5.10+) that rely on this hook won't be able to find it in your React package—hence the error.

This is the best long-term fix to keep your dependencies current and avoid future compatibility issues. Run the appropriate command for your package manager:

  • For npm:
    npm install react@latest react-dom@latest
    
  • For Yarn:
    yarn add react@latest react-dom@latest
    

Restart your dev server after upgrading, and the AppBar component should work as expected.

Solution 2: Downgrade Material UI to a React 17-Compatible Version

If you can't upgrade React right now (due to project constraints), use an older MUI release that doesn't depend on useInsertionEffect. Install these compatible versions:

  • For npm:
    npm install @mui/material@^5.9.0 @mui/icons-material@^5.9.0 @emotion/react@^11.9.0 @emotion/styled@^11.8.1
    
  • For Yarn:
    yarn add @mui/material@^5.9.0 @mui/icons-material@^5.9.0 @emotion/react@^11.9.0 @emotion/styled@^11.8.1
    

Quick Double-Check

Make sure you're not accidentally importing useInsertionEffect directly from React (unless you need it for custom styling)—but in most cases, this error is purely a version mismatch issue.

内容的提问来源于stack exchange,提问作者Jagadish Shrestha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 12:59:05