adrianhajdin / project_crowdfunding

With a stunning design, connected to the blockchain, metamask pairing, interaction with smart contracts, sending Ethereum through the blockchain network, and writing solidity code.
https://jsmastery.pro
704 stars 380 forks source link

Navbar.jsx. Cannot destructure property 'connect' of 'useStateContext(...)' as it is undefined. #13

Open outerspacesoph opened 1 year ago

outerspacesoph commented 1 year ago

The react app isn't working as I keep getting this error in the console: Cannot destructure property 'connect' of 'useStateContext(...)' as it is undefined at Navbar (Navbar.jsx:13:11).

const Navbar = () => { const navigate = useNavigate(); const [isActive, setIsActive] = useState("dashboard"); const [toggleDrawer, setToggleDrawer] = useState(false); const { connect, address } = useStateContext();

matucasal commented 1 year ago

I had the same issue too. Be sure that in the main.jsx in client/src you are using the StateContextProvider

root.render(
  <ThirdwebProvider desiredChainId={ChainId.Goerli}> 
    <Router>
      <StateContextProvider>
        <App />
      </StateContextProvider>
    </Router>
  </ThirdwebProvider> 
)