Is it a good idea to use useRef to prevent rerendering on every input change?

I joined a Frontend bootcamp and now I have to create a registration form as a part of my first project. I want to use the best practices to be… you know… one of the best students to get hired afterwards. The registration form has 9 fields including selcet, textareas and usual inputs. And AFAIK… Read More Is it a good idea to use useRef to prevent rerendering on every input change?

React router with typescript how to import intrinsic attributes

first time using Typescript, i’m rendering a component inside of a map like this: interface chatInterface { sender: string; avatar: string; content: string; time: string; } <> {eachUser?.chats.map((item) => item.messages.map((obj: chatInterface, index: number) => { return <ChatPage key={index} message={obj} />; }) )} </> And the ChatPage component is this: function ChatPage(props: { message: chatInterface })… Read More React router with typescript how to import intrinsic attributes

how to stop re-rendering of child component if parent update the context or state in react js?

how to stop re-rendering of child component if parent update the context or state in react js ? I am already using React.memo still it is re-rendering. this is my child component const Ab = () => { console.log("—ff-ddd"); const pageContext = useContext(PageContext); useEffect(() => { setTimeout(() => { pageContext.updateGlobalMenu({}); }, 5000); }, []); return… Read More how to stop re-rendering of child component if parent update the context or state in react js?

How can I set a key rendering a list in react when two items should be rendered per map iteration?

So I’ve been struggeling with the following issue: I have a function that returns me a number of years (4 years). These years need to each be mapped with two options in a select ( term 1 and term 2 for example). <select> {getSemesterSelection().map((el, key) => { return ( <> <option value={`${el}1`} key={`${el}1`}>{`${el}1`}</option> <option value={`${el}2`}… Read More How can I set a key rendering a list in react when two items should be rendered per map iteration?

Avoid unnecessary component rendering with memo in nextjs

I’am trying to understand react’s behaviour throught nextjs. I have an index.js page with one component Homecard displayed three times and one button that increment a value. Each time I click on button all Homecard components are re-render. index.js import { Homecard } from ‘../components/Homecard’ import { useState } from ‘react’ export default function Home()… Read More Avoid unnecessary component rendering with memo in nextjs

How to associate label with checkbox but not using "for=id"

i have this code: <li><input type="checkbox" id="checkboxThree" value="Alergia3" ><label for="checkboxThree">Alergia 1</label></li> <li><input type="checkbox" id="checkboxFour" value="Alergia4"><label for="checkboxFour">Alergia 1</label></li> <li><input type="checkbox" id="checkboxFive" value="Alergia5"><label for="checkboxFive">Alergia 1</label></li> <li><input type="checkbox" id="checkboxSix" value="Alergia6" ><label for="checkboxSix">Alergia 1</label></li> But I don’t want to use "id" and "for" because I have to do other thing later and I can’t use them. I have see… Read More How to associate label with checkbox but not using "for=id"