編集の要約なし タグ: 差し戻し済み visualeditor |
編集の要約なし タグ: 手動差し戻し |
||
| 1行目: | 1行目: | ||
[[ファイル:react-logo.png|thumb|React|300px]] | |||
* [https://react.dev/learn Quick Start] | |||
==Pick UP== | |||
? operator など、Conditional rendering を使う。<syntaxhighlight lang="jsx" line="1">// if statement | |||
let content; | |||
if (isLoggedIn) { | |||
content = <AdminPanel />; | |||
} else { | |||
content = <LoginForm />; | |||
} | |||
return ( | |||
<div> | |||
{content} | |||
</div> | |||
); | |||
// ? operator | |||
<div> | |||
{isLoggedIn ? ( | |||
<AdminPanel /> | |||
) : ( | |||
<LoginForm /> | |||
)} | |||
</div></syntaxhighlight>When you don’t need the <code>else</code> branch, you can also use a shorter <u>logical <code>&&</code> syntax</u>:<syntaxhighlight lang="jsx" line="1"> | |||
<div> | |||
{isLoggedIn && <AdminPanel />} | |||
</div> | |||
</syntaxhighlight> | |||
==Next.js== | |||
[[Next.js]] を参照。 | |||
2026年6月24日 (水) 03:40時点における版
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 を参照。