Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
453 B
3
Indexable
Never
import React, { useState } from 'react';

const MyComponent = () => {
    const [likes, setLikes] = useState(0);
    // likes = 0
    const [dislikes, setDislikes] = useState(0);
    
    const handleClick = () => {
        setLikes(likes + 1)
        // likes = 1
    }
    
    return <div>
        <button onClick={handleClick}>Likes {likes}</button>
        <button onClick={() => setDislikes(dislikes + 1)}>Dislikes {dislikes}</button>
    </div>
}