How Do You Feel? چالش 4 از جلسهی 12، متوسط
یک state متنی به اسم mood بساز که اولش Calm باشد و آن را در #mood نشان بده.
دکمهی #happy آن را Happy کند و دکمهی #sleepy آن را Sleepy.
<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
</style>
<div id="root" dir="ltr"></div>
<script type="text/jsx">
import { useState } from "react";
import { createRoot } from "react-dom/client";
function App() {
return (
<div>
<h1 id="mood"></h1>
<button id="happy">Happy</button>
<button id="sleepy">Sleepy</button>
</div>
);
}
createRoot(document.getElementById("root")).render(<App />);
</script>
راهنما و جواب این چالش · برگشت به درس جلسهی 12: useState: حافظهی قطعه · چالش بعدی: A Counter Each
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js