Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda