Hi. I followed the instructions (npm i, import the thingy, create state variables, and create the component in my code and I get the following error:
Unhandled Runtime Error
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might have mismatching versions of React and the renderer (such as React DOM)
import { some } from 'lodash';
import { useDispatch, useSelector } from 'react-redux';
import { useRouter } from 'next/router'
import { selectProvider } from '../../store/actions/authActions'
import { toggleFavProduct } from './../../store/actions/userActions'
//import Tilt from 'react-parallax-tilt'
import Description from @.***/react/esm/description'
import CalendarTemplate from '../../node_modules/availability-calendar-react
'
On Tue, Jun 29, 2021 at 11:02 PM Arnold Lee @.***> wrote:
Hey Dan, thanks for the response.
Here's my component:
import { some } from 'lodash';
import { useDispatch, useSelector } from 'react-redux';
import { useRouter } from 'next/router'
import { selectProvider } from '../../store/actions/authActions'
import { toggleFavProduct } from './../../store/actions/userActions'
//import Tilt from 'react-parallax-tilt'
import Description from '
..@.***/react/esm/description'
import CalendarTemplate from '
../../node_modules/availability-calendar-react'
Hi. I followed the instructions (npm i, import the thingy, create state variables, and create the component in my code and I get the following error:
Unhandled Runtime Error Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
Here is my code: return (
{`${firstName} ${lastName}`}
${ ratePerHour }
{ { title } }};
Hi Arnold, thanks for reaching out. Could you provide a little more context of your component? Nothing looks wrong in the return statement
Hey Dan, thanks for the response.
Here's my component:
import { some } from 'lodash'; import { useDispatch, useSelector } from 'react-redux'; import { useRouter } from 'next/router' import { selectProvider } from '../../store/actions/authActions' import { toggleFavProduct } from './../../store/actions/userActions' //import Tilt from 'react-parallax-tilt' import Description from @.***/react/esm/description' import CalendarTemplate from '../../node_modules/availability-calendar-react '
const ProductItem = ({ uuid, age, bio, bookings, currentAddress, firstName, lastName, profileImg, reviews, ratePerHour, stripeCustomerId, title, passions, rating, id}) => { const dispatch = useDispatch() const router = useRouter() const { favProducts } = useSelector(state => state.user); const [ availability, setAvailability ] = React.useState([]) const Calendar = CalendarTemplate({ availability, setAvailability })
const isFavourite = some(favProducts, productId => productId === id)
const clickSelectProvider = () => { const provider = { uuid: uuid, age: age, bio: bio, bookings: bookings, currentAddress: currentAddress, firstName: firstName, lastName: lastName, profileImg: profileImg, reviews: reviews, ratePerHour: ratePerHour, stripeCustomerId: stripeCustomerId, title: title, passions: passions, rating: rating} dispatch(selectProvider(provider)) router.push('/product') }
return (
{`${firstName} ${lastName }`}
${ ratePerHour }
{ { title } }export default ProductItem
On Tue, Jun 29, 2021 at 9:23 AM Dan Proctor @.***> wrote:
And here is a screenshot of the error:
On Tue, Jun 29, 2021 at 11:02 PM Arnold Lee @.***> wrote: