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

257
Views
How to change displayed text in react component?

I installed react-mailchimp-subscribe and I want to change text button because my website is not written in English. i putted this component into div className="pokemon" to have access to him like .pokemon > div > button and could have change styles. Now I want to change text. I try to acces to him by using

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

but I guess in my function is too many errors that it actually work.

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

0

You can update the button label using the state. Please refer the below code

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>
    )
}

Here is the link to codesandbox environment

about 4 years ago · Juan Pablo Isaza Report

0

If you want to do it using dom, you can use the below code.

You have some minor syntax mistake.

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!