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

133
Visualizações
dispatch to redux when screen size is for I.e. large

I have a confusing issue where I want to update a portion of the state of the header when it gets to screen size large. I'm currently using tailwind so I have the following code:

Where when in mobile view, if the template is not hidden, and the screen size gets to large-- the state should automatically get updated with handleHideTemplates...

That's what I'm attempting to do. I understand with this the handle is fired immediately which I don't want...

in mobile view, if the person hits showTemplates, it hides templates immediately.

  const handleHideTemplates = () => {
    dispatch(setShowTemplates({ hidden: 'hidden' }));
    dispatch(setTemplateMargin({ margin: '' }));
  };

  console.log('hidden', hidden);

  return (
    <header
      className={`text-gray-500 text-semibold text-s fill-accent1 
      top-0 z-30 sticky  lg:grid ${
        'grid' ? handleHideTemplates() : null
      } bg-templateBg px-8 ${margin}`}
    >

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

figured it out... instead of conditional inside class..

  useEffect(() => {
    const handleResize = () => {
      if (window.innerWidth >= 1024) {
        handleHideTemplates();
      }
    };

    window.addEventListener('resize', handleResize);

    return () => {
      window.removeEventListener('resize', handleResize);
    };
  }, []);

about 4 years ago · Juan Pablo Isaza 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