Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react increment multipying button click

function Button(props){


  return (
  <button onClick={props.onClickFunction}>
     *{props.increment}
      </button>);
}
function Display(props){
  return(
  <div>{props.message}</div>);
}
function App(){
    const [counter, setCounter] = useState(0);
   const handleClick1 = () => setCounter(counter+1);
     const handleClick2 = () => setCounter(counter*5);
     const handleClick3 = () => setCounter(counter*10);
     const handleClick4 = () => setCounter(counter*100);
  return (
      <>
      <Button onClickFunction= {handleClick1} increment={1}/>
       <Button onClickFunction= {handleClick2} increment={5}/>
       <Button onClickFunction= {handleClick3} increment={10}/>
       <Button onClickFunction= {handleClick4} increment={100}/>
      <Display message={counter}/>
      </> );
}
ReactDOM.render(
<App />,
  document.getElementById('mountNode')

  );
Comment

react increment multipying button click

function Button(props){


  return (
  <button onClick={props.onClickFunction}>
     *{props.increment}
      </button>);
}
function Display(props){
  return(
  <div>{props.message}</div>);
}
function App(){
    const [counter, setCounter] = useState(0);
   const handleClick1 = () => setCounter(counter+1);
     const handleClick2 = () => setCounter(counter*5);
     const handleClick3 = () => setCounter(counter*10);
     const handleClick4 = () => setCounter(counter*100);
  return (
      <>
      <Button onClickFunction= {handleClick1} increment={1}/>
       <Button onClickFunction= {handleClick2} increment={5}/>
       <Button onClickFunction= {handleClick3} increment={10}/>
       <Button onClickFunction= {handleClick4} increment={100}/>
      <Display message={counter}/>
      </> );
}
ReactDOM.render(
<App />,
  document.getElementById('mountNode')

  );
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript change video poster 
Javascript :: electron js nodeintegration 
Javascript :: text input placeholder font family react native 
Javascript :: exploding string with comma using jquery 
Javascript :: sort by date javascript 
Javascript :: javascript .firstordefault 
Javascript :: jquery class selector 
Javascript :: Material-ui add circle outline icon 
Javascript :: change url angular 
Javascript :: second largest number in array javascript 
Javascript :: javascript edit h tag value 
Javascript :: moment format yyyy-mm-dd 
Javascript :: antd tag 
Javascript :: javascript primitive data types 
Javascript :: how to setup icomoon in react js 
Javascript :: 1 dollar in rupees 
Javascript :: nodejs process code 
Javascript :: axios response.json 
Javascript :: Get element by ID with only a partial string 
Javascript :: run node.js code with python 
Javascript :: js remove last char of string 
Javascript :: get key for value javascript 
Javascript :: moment 
Javascript :: javascript static variable in class 
Javascript :: json loop in js 
Javascript :: incoroporate js and css file in html 
Javascript :: axios in functional component 
Javascript :: anchor click event angular refresh page 
Javascript :: sweet alert 2 react 
Javascript :: ternary operator jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =