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

100
Views
Component Creating function not accepting props parameter

this is my react App component. i am observing display of message 'abra-ca-dabra' twice. why is it twice and not once. AS PER ME since in useState(function) function is called once on initialization and again once for each click on my increment/decrement buttons; i should get display of 'abra-ca-dabra' message once for both initial loading and subsequent clicks on my buttons rather than twice... I AM VERY CONFUSED REGARDING TWICE DISPLAY OF MY MESSAGE...

import React, {useState} from 'react'
import logo from './logo.svg';
import './App.css';
import {Alert, Button} from 'react-bootstrap'

function App() {

const display = () => {console.log("abra-ca-dabra"); return 0}
const[count, setCount] = useState(display())

const increment = () => setCount(count + 1)
const decrement = () => setCount(count - 1)

return (

<div className="App">
<Button variant="info" onClick={increment}>+</Button>
<Alert>{count}</Alert>
<Button variant='warning' onClick={decrement}>-</Button>
</div>

);
}

export default App;
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!