編集の要約なし タグ: visualeditor |
タグ: visualeditor |
||
| 3行目: | 3行目: | ||
* [https://react.dev/learn Quick Start] | * [https://react.dev/learn Quick Start] | ||
== | ==Pick UP== | ||
? operator など、Conditional rendering を使う。<syntaxhighlight lang="jsx" line="1">// if statement | ? operator など、Conditional rendering を使う。<syntaxhighlight lang="jsx" line="1">// if statement | ||
let content; | let content; | ||
2026年6月24日 (水) 03:27時点における版
Pick UP
? operator など、Conditional rendering を使う。<syntaxhighlight lang="jsx" line="1">// if statement let content; if (isLoggedIn) {
content = <AdminPanel />;
} else {
content = <LoginForm />;
} return (
{content}
);
// ? operator
{isLoggedIn ? (
<AdminPanel />
) : (
<LoginForm />
)}
</syntaxhighlight>When you don’t need the else branch, you can also use a shorter logical && syntax:<syntaxhighlight lang="jsx" line="1">
{isLoggedIn && <AdminPanel />}
</syntaxhighlight>
Next.js
Next.js を参照。