We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello there! I'm following the tutorial but I cannot make the useEffect work. Everything else in the page is working up to that point, but the dynamic text does not want to work. Here's my code for the Banner component: import { useState, useEffect } from "react"; import { Container, Row, Col } from "react-bootstrap"; import { ArrowRightCircle } from "react-bootstrap-icons"; import headerImg from "../assets/img/header-img.svg"; export const Banner = () => { const [loopNum, setLoopNum] = useState(0); const [isDeleting, setIsDeleting] = useState(false); const toRotate = ["Web Developer", "Web Designer", "UI/UX Designer"]; const [text, setText] = useState(""); const [delta, setDelta] = useState(300 - Math.random() * 100); const period = 2000; useEffect(() => { let ticker = setInterval(() => { tick(); }, delta); return () => { clearInterval(ticker); }; }, [text]); const tick = () => { let i = loopNum % toRotate.length; let fullText = toRotate(i); let updatedText = isDeleting ? fullText.substring(0, text.length - 1) : fullText.substring(0, text.length + 1); setText(updatedText); if (isDeleting) { setDelta((prevDelta) => prevDelta / 2); } if (!isDeleting && updatedText === fullText) { setIsDeleting(true); setDelta(period); } else if (isDeleting && updatedText === "") { setIsDeleting(false); setLoopNum(loopNum + 1); setDelta(500); } }; return ( <section className="banner" id="home"> <Container> <Row className="align-items-center"> <Col xs={12} md={6} xl={7}> <span className="tagline">Welcome to my Portfolio</span> <h1> {Hi! I'm a webdecoded} <span className="wrap">{text}</span> </h1> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione eos illo exercitationem amet iusto doloribus assumenda corrupti fuga libero quos, quasi quis. Suscipit, ipsam ullam autem soluta accusantium natus tenetur! </p> <button> Let's connect <ArrowRightCircle size={25} /> </button> </Col> <Col xs={12} md={6} xl={5}> <img src={headerImg} alt="header_img" /> </Col> </Row> </Container> </section> ); }; Thank you in advance!
import { useState, useEffect } from "react"; import { Container, Row, Col } from "react-bootstrap"; import { ArrowRightCircle } from "react-bootstrap-icons"; import headerImg from "../assets/img/header-img.svg"; export const Banner = () => { const [loopNum, setLoopNum] = useState(0); const [isDeleting, setIsDeleting] = useState(false); const toRotate = ["Web Developer", "Web Designer", "UI/UX Designer"]; const [text, setText] = useState(""); const [delta, setDelta] = useState(300 - Math.random() * 100); const period = 2000; useEffect(() => { let ticker = setInterval(() => { tick(); }, delta); return () => { clearInterval(ticker); }; }, [text]); const tick = () => { let i = loopNum % toRotate.length; let fullText = toRotate(i); let updatedText = isDeleting ? fullText.substring(0, text.length - 1) : fullText.substring(0, text.length + 1); setText(updatedText); if (isDeleting) { setDelta((prevDelta) => prevDelta / 2); } if (!isDeleting && updatedText === fullText) { setIsDeleting(true); setDelta(period); } else if (isDeleting && updatedText === "") { setIsDeleting(false); setLoopNum(loopNum + 1); setDelta(500); } }; return ( <section className="banner" id="home"> <Container> <Row className="align-items-center"> <Col xs={12} md={6} xl={7}> <span className="tagline">Welcome to my Portfolio</span> <h1> {
} <span className="wrap">{text}</span> </h1> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione eos illo exercitationem amet iusto doloribus assumenda corrupti fuga libero quos, quasi quis. Suscipit, ipsam ullam autem soluta accusantium natus tenetur! </p> <button> Let's connect <ArrowRightCircle size={25} /> </button> </Col> <Col xs={12} md={6} xl={5}> <img src={headerImg} alt="header_img" /> </Col> </Row> </Container> </section> ); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello there!
I'm following the tutorial but I cannot make the useEffect work. Everything else in the page is working up to that point, but the dynamic text does not want to work.
Here's my code for the Banner component:
import { useState, useEffect } from "react"; import { Container, Row, Col } from "react-bootstrap"; import { ArrowRightCircle } from "react-bootstrap-icons"; import headerImg from "../assets/img/header-img.svg"; export const Banner = () => { const [loopNum, setLoopNum] = useState(0); const [isDeleting, setIsDeleting] = useState(false); const toRotate = ["Web Developer", "Web Designer", "UI/UX Designer"]; const [text, setText] = useState(""); const [delta, setDelta] = useState(300 - Math.random() * 100); const period = 2000; useEffect(() => { let ticker = setInterval(() => { tick(); }, delta); return () => { clearInterval(ticker); }; }, [text]); const tick = () => { let i = loopNum % toRotate.length; let fullText = toRotate(i); let updatedText = isDeleting ? fullText.substring(0, text.length - 1) : fullText.substring(0, text.length + 1); setText(updatedText); if (isDeleting) { setDelta((prevDelta) => prevDelta / 2); } if (!isDeleting && updatedText === fullText) { setIsDeleting(true); setDelta(period); } else if (isDeleting && updatedText === "") { setIsDeleting(false); setLoopNum(loopNum + 1); setDelta(500); } }; return ( <section className="banner" id="home"> <Container> <Row className="align-items-center"> <Col xs={12} md={6} xl={7}> <span className="tagline">Welcome to my Portfolio</span> <h1> {
Hi! I'm a webdecoded} <span className="wrap">{text}</span> </h1> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione eos illo exercitationem amet iusto doloribus assumenda corrupti fuga libero quos, quasi quis. Suscipit, ipsam ullam autem soluta accusantium natus tenetur! </p> <button> Let's connect <ArrowRightCircle size={25} /> </button> </Col> <Col xs={12} md={6} xl={5}> <img src={headerImg} alt="header_img" /> </Col> </Row> </Container> </section> ); };
Thank you in advance!
The text was updated successfully, but these errors were encountered: