ElemeFE / ElemeFE/element-react
Using the Menu component but getting an error
- Dominant language
- JavaScript
- Stars
- 2.8k
- Forks
- 435
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I'm using the `Menu` component in my project, although some content can be displayed and works fine, but the second level or even multi-level menus don't work correctly, checking the console there is an error message
Here is the React version and Element-react version.
Here are the React version and the Element-react version
| Name | Version |
| :--- | ---- |
| React | ^18.3.1 |
| React-dom | ^18.3.1 |
| element-react | ^1.4.34 |
| element-theme-default | ^1.4.13 |
Here is the source code
```jsx
// App.jsx
import './App.css';
import { Menu } from 'element-react';
function App() {
const onOpen = () => {
console.log('onOpen');
}
const onClose = () => {
console.log('onClose');
}
return (
选项1
选项2
选项3
导航二
导航三
);
}
export default App;
```
```jsx
// main.jsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.jsx';
import './index.css';
import 'element-theme-default';
createRoot(document.getElementById('root')).render(
);
```
The following is the error message
```
Warning: Component "li" contains the string ref "submenu-title". Support for string refs will be removed in a future major release. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref
at li
at SubMenu2 (http://localhost:5174/node_modules/.vite/deps/element-react.js?v=80a16a5a:12502:41)
at ul
at Menu2 (http://localhost:5174/node_modules/.vite/deps/element-react.js?v=80a16a5a:12314:41)
at div
at main
at App
```

```
Warning: Legacy context API has been detected within a strict-mode tree.
The old API will be supported in all 16.x releases, but applications using it should migrate to the new version.
Please update the following components: Menu2, MenuItem2, MenuItemGroup2, SubMenu2
Learn more about this warning here: https://reactjs.org/link/legacy-context
at Menu2 (http://localhost:5174/node_modules/.vite/deps/element-react.js?v=80a16a5a:12314:41)
at div
at main
at App
```

Contributor guide
Assessment
This issue has not been assessed yet.