I'm trying to useContext
on the file app.js
but I receive an error:
_React$useContext is undefined
Normally, I wrap correctly the only component I have, but it tells it's undefined (I saw few answers before asking, some of them tells it's because of wrap problem). How should I approach the error?
import React from "react";
import "./App.css";
import UserProfile from "./components/UserProfile";
import UserContextProvider from "./contexts/UserContext";
// create method toggleStatus that will change the
// status value from true to false. keep in mind that this method has
//to be created before our state!
// create 2 properties for state: status (boolean)
//and toggle (toggleStatus method previously created)
// pass the whole state to the provider as a value
function App() {
function toggleStatus() {
updateUserValue(!userValue);
}
return (
<UserContextProvider>
<UserProfile />
</UserContextProvider>
);
}
};
export default App;