programming:frontend:typescript:react:login:contextを使ったシンプルなログイン機能
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| programming:frontend:typescript:react:login:contextを使ったシンプルなログイン機能 [2022/06/29 05:46] – dot | programming:frontend:typescript:react:login:contextを使ったシンプルなログイン機能 [2022/06/29 08:05] (現在) – dot | ||
|---|---|---|---|
| 行 21: | 行 21: | ||
| setUser({account: | setUser({account: | ||
| } | } | ||
| + | }; | ||
| + | const logout = () => { | ||
| + | setUser(null); | ||
| }; | }; | ||
| 行 36: | 行 39: | ||
| </ | </ | ||
| <button onClick={login}> | <button onClick={login}> | ||
| + | <button onClick={logout}> | ||
| < | < | ||
| </ | </ | ||
| 行 47: | 行 51: | ||
| return ( | return ( | ||
| <div> | <div> | ||
| + | { | ||
| + | user ? | ||
| < | < | ||
| + | : | ||
| + | < | ||
| + | } | ||
| </ | </ | ||
| ); | ); | ||
programming/frontend/typescript/react/login/contextを使ったシンプルなログイン機能.1656481572.txt.gz · 最終更新: by dot
