Reputation: 180
I'm Learning reactjs from some courses/videos and so far I'm really bad at it and I checked a few times and i couldn't see the error. So I can't understand this error. Can somebody help please?? this is my code:
import React, { useState } from 'react';
import CartSummary from './CartSummary'
import CategoryList from './CategoryList'
import ProductList from './ProductList'
import {
Collapse,
Navbar,
NavbarToggler,
NavbarBrand,
Nav,
NavItem,
NavLink,
UncontrolledDropdown,
DropdownToggle,
DropdownMenu,
DropdownItem,
NavbarText
} from 'reactstrap';
const Navi = (props) => {
const [isOpen, setIsOpen] = useState(false);
const toggle = () => setIsOpen(!isOpen);
return (
<div>
<Navbar color="light" light expand="md">
<NavbarBrand href="/">Nortwind App</NavbarBrand>
<NavbarToggler onClick={toggle} />
<Collapse isOpen={isOpen} navbar>
<Nav className="mr-auto" navbar>
<NavItem>
<NavLink href="/components/">Components</NavLink>
</NavItem>
<NavItem>
<NavLink href="https://github.com/reactstrap/reactstrap">GitHub</NavLink>
</NavItem>
<CartSummary cart={this.props.cart}></CartSummary>
</Nav>
<NavbarText>Simple Text</NavbarText>
</Collapse>
</Navbar>
</div>
);
}
export default Navi;
this is the Error:
37 | <NavItem>
38 | <NavLink href="https://github.com/reactstrap/reactstrap">GitHub</NavLink>
39 | </NavItem>
> 40 | <CartSummary cart={this.props.cart}></CartSummary>
| ^ 41 | </Nav>
42 | <NavbarText>Simple Text</NavbarText>
43 | </Collapse>
So can someone help me please?
Upvotes: 2
Views: 756
Reputation: 271
You don't have to use keyword this here, because its functional component.
Btw I recommend you to read about prop-types library. It helps you to define default props to avoid undefined props errors.
Upvotes: 1
Reputation: 558
problem is in this line
<CartSummary cart={this.props.cart}></CartSummary>
Here you need to write
<CartSummary cart={props.cart}></CartSummary>
as you use functional component
Upvotes: 2