From 02b3b6e316e1ef44866a723be39f25264786c1d3 Mon Sep 17 00:00:00 2001 From: priyanshu tiwari Date: Fri, 13 Oct 2023 19:50:18 +0530 Subject: [PATCH 1/3] added dynamic-input --- src/components/Home.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/Home.js b/src/components/Home.js index 2ab19ad..0d39b9d 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -28,6 +28,25 @@ function Home() { console.error("An error occurred:", error); } }; + + useEffect(() => { + adjustWidth(); + }, [name]); + + const adjustWidth = () => { + if (flag) { + const inputField = document.querySelector(".name-field"); + let width = name.length; + console.log(width); + if (width < 1) { + inputField.style.width = "initail"; + } else { + inputField.style.width = width + "ch"; + console.log(width); + } + } + }; + return ( <>
From 8ef93f51176a7f984eed46b21583fd3582de5353 Mon Sep 17 00:00:00 2001 From: priyanshu tiwari Date: Fri, 13 Oct 2023 20:10:28 +0530 Subject: [PATCH 2/3] import useeffect in home page --- src/components/Home.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Home.js b/src/components/Home.js index 0d39b9d..a1e633d 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { TypeAnimation } from "react-type-animation"; import { TTS_API } from "../api"; From 9b1db22da2282790e4d9794ac6a0294b7cb9efe4 Mon Sep 17 00:00:00 2001 From: priyanshu tiwari Date: Sat, 14 Oct 2023 22:42:05 +0530 Subject: [PATCH 3/3] correct the error mistakes --- src/components/Home.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Home.js b/src/components/Home.js index a1e633d..a9d51ce 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -31,7 +31,7 @@ function Home() { useEffect(() => { adjustWidth(); - }, [name]); + }); const adjustWidth = () => { if (flag) { @@ -42,7 +42,6 @@ function Home() { inputField.style.width = "initail"; } else { inputField.style.width = width + "ch"; - console.log(width); } } };