Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
Element scroll in react

I have an element of flex-row that sometime is overflow, based on the content and on the screen size. I want to add a button of scroll right when the element is overflow and the there is more to scroll to right and same for scroll left. I tried to do it with refs, save ref to the element in state and with useeffect catch when the element is changed (the element scroll and width). But it doesn't worked for me, the code inside the useeffect is not triggered when the element changed.

How can I implement this ?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Listen for resize

const [hasButton, setHasButton] = useState(false);
const ref = useRef();
useEffect(() => {
  ref.current.addEventListener('resize', (e) => {
    setHasButton(e.width > 300)
  })
}, [])
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda