Skip to content
Snippets Groups Projects
Commit 5e6189e9 authored by Viarezo's avatar Viarezo
Browse files

git gud

parent ebe7b628
No related branches found
No related tags found
No related merge requests found
import { useState } from "react"; import { useState } from "react";
const Counter = (props) => { const Counter = (props) => {
const [count, setCount] = useState(0); /* const [count, setCount] = useState(0);
const whenUclick = () => setCount(count+1);*/
let lecompte = 0;
const quantuclic = () => lecompte = lecompte+1;
return ( return (
<div class="card" style={{width:"auto", margin: '2em'}}> <div class="card" style={{width:"auto", margin: '2em'}}>
<div class="card-header"> <div class="card-header">
...@@ -10,12 +13,12 @@ const Counter = (props) => { ...@@ -10,12 +13,12 @@ const Counter = (props) => {
<button <button
type="button" type="button"
class="btn btn-primary" class="btn btn-primary"
onClick={()=>setCount(count+1)} onClick={quantuclic}
style={{margin: "1em"}} style={{margin: "1em"}}
> >
Ce bouton incrémente Ce bouton incrémente
</button> </button>
<p style={{margin: "1em auto"}}> genre ça vaut {count}</p> <p style={{margin: "1em auto"}}> genre ça vaut {lecompte}</p>
</div> </div>
) )
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment