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')
);
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')
);