Skip to content

Unhandled Runtime Error. Error: Invalid hook call. #2

Description

@aur42

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:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

Here is my code:
return (



<button type="button" onClick={toggleFavProduct} className={btn-heart ${isFavourite ? 'btn-heart--active' : ''}}>

      <a>
        <img src={profileImg} alt="product" onClick={clickSelectProvider}/>
        {age && 
          <span className="product__discount">Age: {age}</span>
        }
      </a>
  </div>
  <div className="product__description" style={{textAlign: "center"}}>
    <h3 className="product__description__standardized">{`${firstName} ${lastName}`}</h3>
    <div className={"product__price" + (ratePerHour ? 'product__price--discount' : '')} >
      <h4 className="product__description__standardized">${ ratePerHour }</h4>
      { 
        <span><span className="product__description__standardized">{ title }</span></span>
      }
    </div>
  </div>
    <Calendar></Calendar>
</div>)

};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions