I am essentially to display a Login/Signup card when a user clicks on the sign up button of my website. However, the component I am trying to render on click is not showing up. Below is my code –
import "./homePage.css";
import signupCard from "../signupCard/signupCard"; // .jsx file
import { motion } from "framer-motion";
function Header() {
return (
<>
<div className="header">
<ul>
<motion.li
className="li__signup"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.9 }}
transition={{ type: "spring", stiffness: 400, damping: 70 }}
onClick={(e) => {
e.preventDefault();
<signupCard />; // **trying to render card here**
}}
>
Sign Up
</motion.li>
<motion.li
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.9 }}
transition={{ type: "spring", stiffness: 400, damping: 70 }}
>
Contact
</motion.li>
<motion.li
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.9 }}
transition={{ type: "spring", stiffness: 400, damping: 70 }}
>
About
</motion.li>
</ul>
</div>
<img src="../assets/image.png" alt="placeholder" />
</>
);
}
export default Header;
2
Answers
Every
Component
in react must be in therender
and not in anevent
function.Consider doing:
A couple of things.
SignupCard
from your component.SignupCard
instead ofsignupCard
(change it in the source file and the import). Refer to this.