Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { useState } from 'react';
- const TextVote = () => {
- const [votes, setVotes] = useState([
- { text: 'OneOneOne', vote: 0 },
- { text: 'TwoTwoTwo', vote: 5 },
- { text: 'ThreeThreeThree', vote: 0 }
- ]);
- const votesHandler = () => {
- const newClicks = {
- ...votes,
- vote: votes[1].vote + 1
- };
- setVotes(newClicks);
- };
- return (
- <div className='box'>
- <div>{votes[1].text}</div>
- <div>
- <button onClick={votesHandler}>vote</button>
- <div>{votes[1].vote}</div>
- </div>
- </div>
- );
- };
- export default TextVote;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement