请问哪里出错了吗? react版本是16.8.6
报错信息里面提示了有三种可能,
所以大概率是第一种可能
我在本地测试的 BottomNav 组件没有问题,你在
import React,{useState} from 'react'; 上面引用的什么?
// BottomNav.jsx
import React,{useState} from 'react';
function BottomNav (){
const [count,setCount] = useState(0);
return (
<div>
<p>you clicke {count} times</p>
<button onClick={()=>setCount(count+1)}>
click me
</button>
</div>
)
}
export default BottomNav;
//index.js
import React from 'react';
import {render} from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import BottomNav from './components/BottomNav'
render(<BottomNav />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
3 回答2.4k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
我知道了 react版本是16.8.6的同时,react-dom版本也需要是16.8.6,我之前是react-dom版本16.8.3