Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
Next.js, al cargar un lado del cliente de la biblioteca, el componente se representa dos veces y varias veces a medida que cambia el estado del componente principal

Estoy cargando esta biblioteca del lado del cliente emoji-mart porque requiere un objeto de ventana y luego devuelve un componente, mientras llama, el componente se procesa dos veces para comenzar y luego varias veces a medida que cambia el estado del componente principal.

 function EmojiPicker(props = {}) { const ref = useRef() // loading the emojiMart lib clientside coz it requires // window object useEffect(() => { import('emoji-mart').then((EmojiMart) => { new EmojiMart.Picker({ ...props, data, ref }) }) }, []) return <div ref={ref}></div> } function Feed = () => { const[value, setValue] = useState('') return ( ... ... <input value={value} onChange={handleChange}/> ... ... <EmojiPicker/> /* EmojiPicker rendered twice and again and again whenever input state changes */ ) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar React.memo para evitar una reproducción innecesaria. Es fácil de usar, solo tienes que envolver el componente.

 import React from 'react'; const EmojiPicker = React.memo(() => { ... return <div ref={ref}></div> })

React.memo evita volver a renderizar si no hay cambios en las variables de accesorios.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!