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

117
Views
Calling a specific button from a react App.js file

I have a react app with two buttons ("+", "-") that are created by a single component. I am trying to use CountAPI to store the input data from the two buttons. So far i am able to get the input and update the countAPI site to interperate either plus or minus from the buttons. The problem i am having is seperating the two buttons. It works for both buttons but i havent been able to figure out how to call the specific "+" or "-" button. For example, in the code below, its set to increment by +1 when i press the button, but i can press either the "+" or "-" button and they both increment by +1.

index.js

    import React from 'react';
    import ReactDOM from 'react- 
    dom/client';
    import './index.css';
    import App from './App';
    import reportWebVitals from 
    './reportWebVitals';
    import countapi from 'countapi-js';
    import "./App.js";
    
    const alb = ReactDOM.createRoot(document.getElementById('alb'));
    alb.render(
      <React.StrictMode>
<App />
      </React.StrictMode>
    );


    document.getElementById("alb").addEventListener("click", () => {
      countapi.update('f1AppAlbon', 'fbda1857-916b-413d-8b7b-503651f3c52c', +1).then((result) => {
alert(`The magic button has been pressed ${result.value} times.`);
      });
    });

App.js

    import React, { useState } from "react";
    import Button from "./components/Button";
    import "./App.css";
    import "./index.js";

    <div class="buttons">
      <Button title={"-"} action={decrementCount} class="minus"></Button>
      <Button title={"+"} action={incrementCount} class="plus"></Button>
    </div>

index.html

    <div id="+alb"></div>

Sorry if some terminology is wrong, im still new to this.

about 4 years ago · Juan Pablo Isaza
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!