Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
個人的に楽しかった実装2022
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Azusa Okamoto
December 12, 2022
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
個人的に楽しかった実装2022
Azusa Okamoto
December 12, 2022
More Decks by Azusa Okamoto
See All by Azusa Okamoto
GraphQLでAPI開発 やってみよう!
azunyan
0
43
「わたし色」の見方で拓く世界
azunyan
0
30
ちゃんとSvelte, Hello Worldした!
azunyan
0
79
最近取り組んでいることについて喋ってみる
azunyan
0
24
フロントエンドエンジニアが関数型プログラミングに出会った話
azunyan
0
120
TECH WOMAN KANSAIの 取り組みと今後~2024年の振り返りと2025年へ~
azunyan
0
100
Go初心者が開発やってみた!
azunyan
1
580
デブサミウーマン2023 アウトプットって何が良いの?
azunyan
0
1.3k
TestCaféでE2Eテスト!
azunyan
0
160
Other Decks in Programming
See All in Programming
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
660
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
0
150
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
200
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
100
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
1
460
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
180
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
660
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
130
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
160
Deep dive into the select statement (GopherCon UK)
jespino
0
170
信頼性の目標を誰も求めてない
shubox
0
480
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
230
Designing for Timeless Needs
cassininazir
1
470
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
440
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
310
KATA
mclloyd
PRO
35
15k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
640
Thoughts on Productivity
jonyablonski
76
5.4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
490
Transcript
個人的に楽しかった実装 2022 あずにゃん 20221211_TECH WOMAN KANSAI_クリスマス勉強会
今日お話しすること 今年1年で、 個人的に「できて良かったな〜」と思う実装について!
今日お話しすること 1. React Hook Formで動的フォーム 2. Express×React×PostgreSQL 3. まとめ 都合により、一部型指定
を省略してます!
1. React Hook Formで動的フォーム 2. Express×React×PostgreSQL 3. まとめ
React Hook Form Reactで簡単にフォームを作成できるライブラリ。 入力した値の取得やバリデーションなどを行える。
None
< > < > </ > < {... ( )}
/> < > < /> < { ( )} /> </ > </ > form label label input div div form タスク: register handleSubmit submitForm 'title' '登録' BackToHomeButton SubmitButton onClick text = = 基本のフォーム〜JSX〜 入力値の登録 フォーム送信実行
const => const const => div div = () {
, , , = (); = ( : ): { (); }; ( ~略~ ); }; SampleForm register handleSubmit watch reset useForm submitForm reset { } // フォーム送信 // 後ほどデータベースへの追加処理を行う // フォームを空にする。 data any void return < > </ > 基本のフォーム〜処理〜
動的フォーム
const => const const = () { , , ,
= ({ : : : }); , , = ({ , : }); ~略~ ( ~略~ ); }; SampleDynamicForm register handleSubmit reset useForm { } prepend append useFieldArray { } { '' } { } 'sample' control [ ] fields defaultValues sample title control name // 入力値を格納するオブジェクトのキー名となる return 動的フォーム〜処理〜 デフォルト値が入ったオブジェクトを要素とする配列
< > < = </ > < > < >
</ > < > < { ( )} /> </ > </ > < = </ > </ > form button => button => div label label div input $ div div button => button form {() ( )}>先頭に追加 . (( : , : ) ( タスクNo.{ }: ... )) {() ( )}>後ろに追加 ~略~ type onClick title: field index key field id index . index . type onClick title: "button" { ''} { { } `sample title` } "button" { ''} = = = prepend map register { } append fields any number . 動的フォーム〜JSX〜 配列を展開していく
フォーム送信すると... sampleオブジェクト 配列! フィールド単位 の中に、 ↓ で 配列の要素となっている!
完成したフォーム、実演してみる。
1. React Hook Formで動的フォーム 3. まとめ 2. Express×React×PostgreSQL
Express×React×PostgreSQL ・バックエンド →Express ・データベース →PostgreSQL ・フロントエンド →React pg-promiseという ライブラリを使うよ〜!
今回使うSQL文 ① 追加 INSERT INTO テーブル名(カラム名) VALUES(値) ② 取得(全件) SELECT
* FROM テーブル名 ③ 削除 DELETE FROM テーブル名 WHERE カラム名 = 値
PostgreSQLの実行〜接続〜 const const const = ( )(); = { .
. , . . , . . , . . , . . }; = ( ); pgp connectionConfig DB_HOST DB_PORT DB_DATABASE DB_USER DB_PASSWORD, db connectionConfig require pgp 'pg-promise' // DB接続に必要な情報 // DB接続 host: processenv port: processenv database: processenv user: processenv password:processenv
PostgreSQLの実行〜実行〜 // リクエストボディとして渡された値を取得 // 実行したいSQL文を事前に作成 // 実行 const const =>
= . . ; = ; . ( , ) . ( { . ( ); . ( ); }); title sql db sql [title] reqbodytitle data console data res data 'INSERT INTO tasks(title) VALUES($1)' manyOrNone then log send pg-promiseでは、返される結果の多さに応じて、メソッドを使いわけ!
PostgreSQLの実行〜例〜 const const => const const => = ( );
= (); ~略~ . ( , ( , ) { = . . ; = ; . ( , ) . ( { . ( ); . ( ); }); }); express app app title sql db sql [title] require express post manyOrNone then log send 'express' '/addTask' 'INSERT INTO tasks(title) VALUES($1)' req res reqbodytitle data console data res data
フォーム送信とデータ追加~ReactでAPI実行~ const async => const const = ( : ):
< > { : = { : . }; = . ( , ); . ( ); (); }; submitForm post log reset data title datatitle console any Promise void AddTaskParamType param response axiosClient param response // データベースに追加するAPI実行 // フォームを空にする。 await '/addTask'
フォーム送信とデータ追加、実演してみる。
1. React Hook Formで動的フォーム 2. Express×React×PostgreSQL 3. まとめ
まとめ ・useFieldArrayを用いて、フィールドを増減させられる フォームを作成できた (感動したw) ・データベース操作やってるの、面白いな〜と思った ・個人でバックエンドを経験できたこと自体が感動
まとめ ・他にも、Next.jsやmicroCMS、Svelte触ったりとか、 色々な技術に触れた1年間でした!
ご清聴ありがとうございました!!