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

261
Visualizações
MUI ScrollToTop component with the useScrollTrigger hook is not working

I'm creating a ScrollToTop component by using MUI useScrollTrigger hook https://mui.com/material-ui/react-app-bar/#usescrolltrigger-options-trigger

Here is the sample code: https://codesandbox.io/s/stackoverlow-mui-usescrolltrigger-er9z4y

Problems

  1. The ScrollTop component doesn't appear after scrolling some pixels even after scrolling to the bottom of the page.

Here is the screenshot. The ScrollToTop component should appear around the area I marked.
As we could see that the trigger value from the useScrollTrigger hook returns a false value. It should return a true value if we scrolled the page. enter image description here

  1. If we uncomment the ScrollToTop component, the ScrollToTop component would appear. Then if we click the ScrollToTop component, the screen would not go to the top of the page.

Here is the screenshot. enter image description here

Step To Reproduce

For problem 1:

  1. Open the demo (codesandbox link) above.
  2. Scroll to the bottom of the page.

For problem 2:

  1. Open the demo (codesandbox link) above.
  2. Comment only the ScrollToTop component.
  3. Scroll to the bottom of the page.
  4. Click the ScrollToTop component.

Expected conditions

  1. For problem 1: the ScrollTop component appears after scrolling some pixels.
  2. For problem 2: the ScrollTop component should bring the screen to the top of the page after being clicked.
about 4 years ago · Juan Pablo Isaza
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