タグ: visualeditor |
編集の要約なし タグ: visualeditor |
||
| 1行目: | 1行目: | ||
[[ファイル:react-logo.png|thumb|React|300px]] | [[ファイル:react-logo.png|thumb|React|300px]] | ||
* | * [https://react.dev/learn Quick Start] | ||
==JavaScript== | ==JavaScript== | ||
2026年6月24日 (水) 03:26時点における版
JavaScript
? 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 を参照。