Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
I want to call two const in the same onclick

How can I call two consts in the same onclick event? One is to open a popup form and the other is to make an emoji explosion effect every time I click the button.

This is the code when the button is clicked it shows the popup form, but the emoji explosion does not appear.

const CTA = () => {
  const [buttonPopup, setButtonPopup] = useState(false)

  const explosion = (posX, posY) => emojisplosion({
    emojis: ["๐ŸŒŒ", "โœจ", "โญ", "๐Ÿ’ซ", "๐Ÿš€", "๐ŸŒŽ", "๐ŸŒ‘"],
    physics: {
      gravity: -0.20,
      initialVelocities: {
        rotation: {
          max: 24,
          min: -20
        },
        rotationDecelaration: 2.01,
        y: {
          max: 17,
          min: 14.7,
        },
        x: {
          max: 4,
          min: 1.3,
        },
      },
    },
    position: () => ({
      x: posX,
      y: posY
    }),
  });
  const blast = event => {
    explosion(event.clientX, event.clientY)
  }

  
  return (
    <div className="vimcash__cta">
      <div className="vimcash__cta-content">
        <p>Comienza con nosotros</p>
        <h3>Comunicate hoy mismo y empezemos a explorar posiblidades infintas.</h3>
      </div>
      <div className="vimcash__cta-btn">
        <button type="button" onClick={() => {setButtonPopup(true); blast();}}>Contactar</button>
      </div>
        <Popup trigger={buttonPopup} setTrigger={setButtonPopup}>
          <h3>Popup formulario de contacto</h3>
          <p>trigger popup form contacto</p>
        </Popup>
    </div>
  )
}

about 4 years ago ยท Juan Pablo Isaza
2 answers
Answer question

0

try to combine them as below:

const allFunc = (e) => {
    explosion(e.clientX, e.clientY)
    setButtonPopup(true)
}
<button onClick={allFunc}>Contactar</button>
about 4 years ago ยท Juan Pablo Isaza Report

0

You can try using the && operator or you can addy curly brackets and then call the functions. Like this:

<button onClick={(e) => {
// call your functions here
explosion(e.clientX, e.clientY);
setButtonPopup(true);
}}>Contactar</button>

Or this with the && operator

<button onClick={func1() && func2()}>Contactar</button>
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!