Chapter 10 - use client side components for state

This commit is contained in:
2023-12-21 21:09:51 +01:00
parent 01fc574c38
commit 2fbe08bbed
2 changed files with 17 additions and 8 deletions

15
app/like-button.js Normal file
View File

@@ -0,0 +1,15 @@
'use client';
import { useState } from 'react';
export default function LikeButton() {
const [likes, setLikes] = useState(0);
function handleClick() {
setLikes(likes + 1);
}
return (<button onClick={handleClick}> Like ({likes}) </button>)
}