gpt4 book ai didi

javascript - 不支持直接渲染 并将在未来的主要版本错误中删除

转载 作者:行者123 更新时间:2023-12-05 08:35:54 25 4
gpt4 key购买 nike

我收到以下错误:

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

这是我的 app.js 组件:

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;

我正在尝试使用 useContext Hook 。

最佳答案

我的解决方案正在改变:

import AuthProvider from "./context/AuthContext";

收件人:

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

我是 React 新手,可能是因为 AuthProvider 不是默认导出

关于javascript - 不支持直接渲染 <Context> 并将在未来的主要版本错误中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71285222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com