I am learning from udemy but that course is from v5.I dont know what is equivalent to render and how to send props with it ? Also, in bottom of the code if element is undefined it should go to "NotFound" but its not working too.
<Routes>
<Route
exact
path="/home"
render={(props) => (
<ProductList
{...props}
products={this.state.products}
currentCategory={this.state.currentCategory}
info={productInfo}
addToCart={this.addToCart}
/>
)}
></Route>
<Route exact path="/cart" element={<CartList />} />
<Route element={<NotFound />} />
</Routes>
CodePudding user response:
In the v6 you can pass props directly to the element. No need to use render anymore
<Route exact path="/cart" element={<CartList {...props} />} />
CodePudding user response:
<Routes>
<Route exact path="/" element={<ProductList
{...this.props}
products={this.state.products}
currentCategory={this.state.currentCategory}
info={productInfo}
addToCart={this.addToCart}
/>}></Route>
<Route exact path="/cart" element={<CartList />} />
<Route path="*"element={<NotFound />} />
</Routes>
I solved.