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

186
Visualizações
Onclick not working on React Worldmap SVG

I'm kinda lost. Basically, i'm trying to use this [map SVG for react][1]. And I am trying to highlight a specific part on the map when a button/checkbox is clicked by pushing an object to an Array. The object is pushed successfully (I console logged it and can see the new object in the array). However, the map doesn't highlight for some reason. Here's a copy of my entire code:

import './App.css';
import React from 'react';
import Worldmap from 'react-svg-worldmap';
import './styles/map.css'

function App() {


function highlightUS () {



        data.push({country: "us", value: 1000000});

console.log(data)

    
}     

  const data = [
    { country: "cn", value: 1389618778 }, // china
    { country: "in", value: 1311559204 }, // india
    
  ];

console.log(data)


  return (
    <div className="App">
          <header>
              Testing Map
          </header>

          <Worldmap 
            color="blue"
            title="World Language Map"
            value-suffix="languages"
            size="xl"
            data={data}

          />


          <div className="langBox">
                      <h1>Language Search</h1>

                      <input type="checkbox" id='usa' onClick={highlightUS}/> USA
                      <input type="checkbox" id='canada'/> Canada
                      <input type="checkbox" id='brazil'/> Brazil
                      <input type="checkbox" id='uk'/> UK

            </div>
    </div>
  );
}

export default App;

Like I said, it successfully pushes the highlightUS object into the data array but the country doesn't get highlighted. [1]: https://www.npmjs.com/package/react-svg-worldmap

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