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
850
開発環境でDocker使ってみた
f96q
1
2.4k
2013年を振り返って
f96q
0
790
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
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.8k
[2026-10-09]一枚の布で作らなくてもいい。 信頼性は「パッチワーク」で紡がれる~既存の運用と新しい可能性をつなぎ合わせてきたCREの話~
tosite
0
110
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
130
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.6k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
290
golang-bob.pdf
iwatsukayura
0
130
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
Railsバージョンを4倍にした話
optim
0
510
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
300
ActionController meets Protocol Buffers
sorah
0
650
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
130
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
850
Making the Leap to Tech Lead
cromwellryan
135
10k
Building an army of robots
kneath
307
47k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
480
Amusing Abliteration
ianozsvald
1
350
How STYLIGHT went responsive
nonsquared
100
6.3k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Designing Experiences People Love
moore
143
24k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
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をハンドリングし てログインページにローケーション