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

106
Visualizações
Is there a way to play a sound when you load the screen using reactJs?

I'm making a website using react for the first time. I would like when you first load the site my mp3 sound plays once and just stops. Here is my react code so far

  import React, {Component} from 'react';
  import {render} from 'react-dom';
  import Sound from 'react-sound'
  import './styles.scss';
  import sun from "/src/Images/cuteMovingSun.gif"
  import hereComesTheSun from '/src/Images/HereComesTheSunEdit.mp3'
  import useSound from 'use-sound';


const Title = () => {
 return <div>Good Morning, Sunshine!</div>;
 };

const [play] = useSound('hereComesTheSun');


render(<Title />, document.getElementById('root'));
render( <img className = "sun" src={ sun }/>, document.getElementById('mySun'));

I'm still new to react so I'm still unclear on a lot of things.

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