Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
個人的に楽しかった実装2022
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Azusa Okamoto
December 12, 2022
Programming
160
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
49
「わたし色」の見方で拓く世界
azunyan
0
33
ちゃんとSvelte, Hello Worldした!
azunyan
0
86
最近取り組んでいることについて喋ってみる
azunyan
0
28
フロントエンドエンジニアが関数型プログラミングに出会った話
azunyan
0
130
TECH WOMAN KANSAIの 取り組みと今後~2024年の振り返りと2025年へ~
azunyan
0
110
Go初心者が開発やってみた!
azunyan
1
590
デブサミウーマン2023 アウトプットって何が良いの?
azunyan
0
1.3k
TestCaféでE2Eテスト!
azunyan
0
160
Other Decks in Programming
See All in Programming
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
140
ジョジョの世界をXRで再現する
mofurune
0
150
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
110
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
1
310
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
650
Kubernetes祭り #2 OP/ED
bells17
0
110
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
150
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
210
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.3k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.4k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
730
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
The browser strikes back
jonoalderson
0
1.8k
Fireside Chat
paigeccino
43
4.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
GitHub's CSS Performance
jonrohan
1033
470k
Everyday Curiosity
cassininazir
0
350
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
810
First, design no harm
axbom
PRO
2
1.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
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年間でした!
ご清聴ありがとうございました!!