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

261
Views
¿Cómo cambiar el texto mostrado en el componente de reacción?

Instalé react-mailchimp-subscribe y quiero cambiar el botón de texto porque mi sitio web no está escrito en inglés. Puse este componente en div className="pokemon" para tener acceso a él como .pokemon > div > button y podría tener estilos de cambio. Ahora quiero cambiar el texto. Intento acceder a él usando

 useEffect(() = > { document.addEventListener("load", function(){ (".pokemon>div>button").innerHtml("Wyślij") }); }, [])

pero supongo que en mi función hay demasiados errores que realmente funcionan.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede actualizar la etiqueta del botón usando el estado. Por favor, consulte el siguiente código

 import React, { useEffect, useState } from 'react' export default function App() { const [buttonLabel, setButtonLabel ] = useState("I'm Button"); useEffect(() => { setButtonLabel("Wyślij") }, []) return ( <div className="pokemon"> <div> <button> {buttonLabel}</button> </div> </div> ) }

Aquí está el enlace al entorno de codesandbox

about 4 years ago · Juan Pablo Isaza Report

0

Si quieres hacerlo usando dom, puedes usar el siguiente código.

Tienes un pequeño error de sintaxis.

 useEffect(() = > { document.addEventListener("load", function(){ document.querySelector(".pokemon").querySelector("div").querySelector("button").innerHTML = "Wyślij"; }); }, [])
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!