Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering <Context> directly is not supported and will be removed in a future major release error

i am getting the following errror:

Warning: Rendering directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?

This is my app.js component:

import React from "react";
import "./App.css";
import "bootstrap/dist/css/bootstrap.min.css";
import Navbar from "./components/Navbar";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "./pages/Home";
import SignInSide from "./components/SignInSide";
import AboutUs from "./pages/AboutUs";
import ourservices from "./pages/OurServices";
import portfolio from "./pages/portfolio";
import SignUp from "./components/signup";
import booking from "./pages/book";
import PreviousBookings from "./pages/PreviousBookings";
import BookingContext from "./context/bookings/BookingContext";
function App() {
return (
<>
  <BookingContext>
    <Router>
      <Navbar />
      <Switch>
        <Route path="/" exact component={Home} />
        <Route path="/aboutus" component={AboutUs} />
        <Route path="/ourservices" component={ourservices} />
        <Route path="/developer" component={portfolio} />
        <Route path="/login" component={SignInSide} />
        <Route path="/signup" component={SignUp} />
        <Route path="/booking" component={booking} />
        <Route path="/booking-history" component={PreviousBookings} />
      </Switch>
    </Router>
  </BookingContext>
</>
 );
 }

export default App;

I am trying to use the useContext hook.

like image 853
Vedant Shah Avatar asked Sep 18 '25 19:09

Vedant Shah


1 Answers

Solution for me was changing:

import AuthProvider from "./context/AuthContext";

To:

import {AuthProvider} from "./context/AuthContext";

I'm new with React, might be because AuthProvider is not the default export

like image 97
Hakun Avatar answered Sep 20 '25 10:09

Hakun