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
Datapiaのフロントエンドについて
Search
danny
November 12, 2020
Programming
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Datapiaのフロントエンドについて
danny
November 12, 2020
More Decks by danny
See All by danny
新規サービスの技術選定と設計
f96q
1
18k
Vue.jsとRailsで作るWebアプリケーション
f96q
0
840
開発環境でDocker使ってみた
f96q
1
2.4k
2013年を振り返って
f96q
0
780
Git勉強会@KRAY
f96q
1
2.2k
等強Ruby会議10に参加しての感想
f96q
2
970
Inside Tripclip
f96q
2
1.6k
Other Decks in Programming
See All in Programming
Intent as Code
shoppingjaws
6
1.1k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
140
Webの地図
yosuke_furukawa
PRO
6
4.9k
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.5k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
320
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
390
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.2k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
890
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
18
18k
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
240
Workers Cache を知る
syumai
0
300
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
420
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.7k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
250
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Site-Speed That Sticks
csswizardry
13
1.5k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
310
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Limits of Empathy - UXLibs8
cassininazir
1
690
YesSQL, Process and Tooling at Scale
rocio
174
15k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
840
Transcript
Datapiaのフロントエンドについて 2020.11.12 コネヒトマルシェオンライン 宮城 史明
今日話すこと 2 ここ2年ほど開発してるDatapiaというプロ ダクトのフロントエンドについての話をし ます Datapiaとは • 複数クラウド(DB、ストレージ)に対 して、クエリ操作、データ転送、ワー クフロー、権限管理などをノンプログ
ラミングで実行できるクラウド型 iPaaSです
Datapiaについて 3 • フロントエンドがReactでバックエン ドがRuby on Rails • ログインページでログインした後は Single
Page Application構成 • フロントエンドの規模感 ◦ およそ3万4千桁 (TypeScript, TSX) ◦ React Component数は373
構成 フロントエンド • TypeScript • React • Redux ◦ React
Redux ◦ TypeScript FSA Reducers • React Router • styled-components • Apollo Client バックエンド • Ruby on Rails (GraphQL API Server)
Railsでwebpackを使う Webpackerを使わない理由 • フロントエンドエンジニアじゃなくても扱えるように整備された状態で使えるのはメ リットたが、その反面細かい部分まで調整したい場合はいじりずらい ◦ webpackの設定ファイルと書き方が違う ◦ webpackのあの設定、Webpackerだとどう設定するのかを調べないと分からない webpack-assets-pipleline
• webpackで生成したファイルのハッシュ値付きのURLが入ったmanifest.jsonを生成で きる ◦ Railsでassets precompileする必要がなくなる ◦ Railsでもwebpackを使って開発できるようになる 参考 • https://infinum.com/the-capsized-eight/squeezing-webpack-into-backend-fram eworks 5
Babelの設定 6 "presets": [ [ "@babel/preset-env", { "targets": { "chrome":
"75", "firefox": "68", "edge": "18" }, "useBuiltIns": "usage", "corejs": 3 } ], "@babel/preset-react", "@babel/preset-typescript" ] useBuildIns usage • 対応ブラウザのバージョンを定義して おくと、その定義をみて自動で必要な polyfillのみを使ってビルドされる
ESLintで禁止してるもの import/no-default-export • 任意の名前でインポートできるので後から名前を変えたり、使われてる箇所をさがすときに大変な ため no-restricted-syntax • TSEnumDeclaration ◦ 後から入ったエンジニアがenumかUnion型どっち使うのか混乱しないように
• TSInterfaceDeclaration ◦ 後から入ったエンジニアがtypeとinterfaceどっち使うのか混乱しないように ◦ interfaceは既存の定義されてる名前のまま拡張できるので公開するライブラリで使う方針 • ForInStatement, ForOfStatement, VariableDeclaration[kind='let'] ◦ 副作用が起きない書き方によせるため • LabeledStatement ◦ go to使われるとコード読みづらくなるため • WithStatement ◦ withで省略されると出どころが追いづらくなってコードが読みづらくなるため 参考 • https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base /rules/style.js#L339-L357 7
例外通知 8 componentDidCatch(error: Error, errorInfo: ErrorInfo): void { Sentry.withScope((scope) =>
{ scope.setExtras(errorInfo as any) Sentry.captureException(error) }) this.setState({ hasError: true }) } React Error Boundaryで補足した例外 をSentryに送る • Redux Storeの中身をsentryに送信 するような実装はしない ◦ 送ったほうがデバックはしやすくな るが、Redux Storeはバックエンド のAPIからユーザーの情報が入って いて、内容によっては外部のサービ スに送ってはまずいものが含まれて ることがあるため
React Hooksの使い方 9 const history = useHistory() const { id
} = useParams<{ id: string }>() const { currentOrganization, currentUser, user } = useSelector((state: RootState) => ({ currentOrganization: state.organization.currentOrganization, currentUser: state.user.currentUser, user: state.user.user, })) const dispatch = useDispatch() useEffect(() => { dispatch(actions.user.fetchUser({ id })) }, [id]) APIで取得した値をRedux Storeから取り出 して表示する • useHistory • useParams • useSelector • useDispatch
多言語化 10 <FormattedMessage id="models.organization.logo" /> 最初から多言語化することを前提で作って おく • 後から多言語化しようとすると、ほぼ すべての画面に影響が出るため手間が
大きい React Intl • ECMA Script標準の国際化APIのIntlを React Componentで扱える
アイコン、ロゴ画像 全てSVGで作成 • 同じ画像で@2xのような複数の画像サ イズの画像を用意する必要がなくなる • webpackでビルドした時のbundleサイ ズの軽量化 SVGR •
https://github.com/gregberge/svgr • SVGをReact Componentに変換
バックエンドとの通信 12 function errorLink(): ApolloLink { return onError((response: any) =>
{ if (response.networkError && response.networkError.statusCode === 401) { location.href = '/users/sign_in' } }) } Apollo Client • GraphQLクライアント SPA特有の問題 • ログインセッションが切れた状態で画 面を操作するとなにも反応がなくなっ てしまう ◦ ApploLinkでonErrorをハンドリングし てログインページにローケーション