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

153
Visualizações
how to make a single div from an array of divs appear to a component every 24 hours?

I think I'm on the right track, but basically, I have a file with 3 divs in an array that I want to display one every 24 hours.

I found a wordle clone on Github that essentially does this with a "getWordOfTheDay" function but I'm confused where I would put these random divs so that they render in the main component.

i feel like the solution would be finding a different way to render DisplayComponent as a JSX element instead of doing this: < DisplayComponent >< /DisplayComponent >

here is my 'app' component where I want to display a certain div at a time on the home screen. these divs are colored differently with CSS so I can distinguish which one is which.

    import React, { Component } from 'react';
    import './App.css';
    import Layout from './components/Layout'
    
    
    function daysSinceStart() {
      const start = (new Date(2022, 2, 1)).getTime();
      const now = (new Date()).getTime();
      return Math.floor( (now - start) / (1000 * 60 * 60 * 24));
    }
    
    export class App extends Component {
        render() {
        const componentsArray = [<div className="a"></div>, <div className="b"></div>, <div className="c"></div>]
        const DisplayComponent = componentsArray[daysSinceStart % componentsArray.length];
            return (
        <Layout>
           <div className='title'>welcome</div>
            <div className="page">
                 <div className="container">
                 <DisplayComponent>
                      <img 
                         src=""
                         alt="" id="img"
                         className="img" draggable= {false}/>
                      </DisplayComponent>
                </div>
              </div>
           
           </Layout>
            

            );
        }
    }
    
    export default App;

thank you very much in advance.

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