React Hook “useSelector“ cannot be called at the top level. React Hooks must

一般报这个错的话,就是useSelector写在了函数组件外边

解决办法就是

// 项目的根组件

import { useSelector } from "react-redux";

function App() {
  const count = useSelector(state => state.counter)

  return 

this is title

{count}
; } export default App;

你可能感兴趣的:(react.js,javascript,前端)