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
ReactとReact Nativeを共通化させる試みの話 - FUKUOKA Enginee...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yusuke Otawa
September 22, 2018
Programming
3.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ReactとReact Nativeを共通化させる試みの話 - FUKUOKA Engineers Day 2018 ~Autumn~
Yusuke Otawa
September 22, 2018
More Decks by Yusuke Otawa
See All by Yusuke Otawa
少人数でサービスをすばやく開発するためのRails活用事例 - Rails Developers Meetup 2019
tawachan
3
6.2k
Other Decks in Programming
See All in Programming
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
820
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
420
AmebaブログはKMPから卒業します
kmars0605
0
340
SODA - FACT BOOK(EN)
sodainc
1
220
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
160
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
1
340
AI Augmentation Techniques with Liberty
ivargrimstad
1
430
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
230
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
200
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
590
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
240
Featured
See All Featured
From π to Pie charts
rasagy
1
440
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
560
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
480
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Bash Introduction
62gerente
615
220k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How STYLIGHT went responsive
nonsquared
100
6.4k
Agile that works and the tools we love
rasmusluckow
331
22k
The Cult of Friendly URLs
andyhume
79
7.1k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Transcript
React と React Native を 共通化させる試みの話 (序章) pixiv Inc. Yusuke
Otawa @tawachan39 2018.6.5
自己紹介 • 大多和 祐介(オオタワ ユウスケ) ◦ twitter: @tawachan39 • ピクシブ(pixiv)
福岡オフィス • 東京生まれ・埼玉育ち・福岡歴1年弱 2 tawachan
3
でやっていること 4 API Server Web/PWA iOS CDN
普通につらい 5
iOSとWebの二重開発でスピード感に欠ける 6 6 API Server Web/PWA iOS CDN
どうにか一本化したい 7
8
iOSとWebの二重開発でスピード感に欠ける 9 9 API Server Web/PWA iOS CDN
• どうしたら React でいい感じに ウェブとアプリを作れるか • 今のところ一番良さそうな方法 • 実践登用したわけではないのでただの共有段階 •
前提: ◦ 最速で柔軟に試行錯誤できる(≒ 開発速度) > 体験の細かな質の向上 ◦ 知見があればぜひ共有していただけると嬉しい! 10 今日話すこと
• React / React Native ってどんなもの • React で create-react-app
を使うべきか • React Native で Expo.io を使うべきか 11 今日話さないこと
12 試したこと 1. React / React Native を同じリポジトリに置いてデータ周りを共通化する 2. React
Native に React Native for Web を導入する 3. ReactXP でプロジェクトを作成する 4. React Native Dom を導入する
① React / React Native を同じリポジトリに 置いてデータ周りを共通化する 13
• React と React Native のプロジェクトをそれぞれ作る • View はそれぞれの実装をして、Data 周りは共通化させる
どういうこと? 14 共通化
• React / React Native の独立し たプロジェクトを併存させる • redux など見た目に関わらない
部分を common に切り出す • 各プロジェクトから common 参 照する ディレクトリ構成 15 . ├── common │ ├── reducers │ └── actions ├── native │ ├── ios │ ├── android │ ├── src │ ├── package.json │ ├── tsconfig.json │ ├── tslint.json │ └── yarn.lock └── web ├── package.json ├── public ├── src ├── tsconfig.json ├── tslint.json ├── webpack.config.js └── yarn.lock
• ただのReact と React Native の プロジェクトなのでなんでもできる • Native /
Web 特有の実装も問題 なくできる • データ周りを切り分けるモチベー ション 自由で良さそう 16 . ├── common │ ├── reducers │ └── actions ├── native │ ├── ios │ ├── android │ ├── src │ ├── package.json │ ├── tsconfig.json │ ├── tslint.json │ └── yarn.lock └── web ├── package.json ├── public ├── src ├── tsconfig.json ├── tslint.json ├── webpack.config.js └── yarn.lock
• package.json が2つ(3つ)ある • ほぼ内容が同じ tsconfig.json と tslint.json が生まれる •
common 配下のファイルの責任 の所在が怪しい • そもそも開発早くなるのか? 管理が複雑でつらい 17 . ├── common │ ├── reducers │ └── actions ├── native │ ├── ios │ ├── android │ ├── src │ ├── package.json │ ├── tsconfig.json │ ├── tslint.json │ └── yarn.lock └── web ├── package.json ├── public ├── src ├── tsconfig.json ├── tslint.json ├── webpack.config.js └── yarn.lock
ちょっと微妙 18
② React Native に React Native for Web を導入する 19
• React Native のプロジェクトに後入れできる • React Native のコンポーネントを Web で使える形にトランスパイルしてくれる
• React Native をそのままが使えるので View も共通化できる • (一部対応していないコンポーネントが現段階ではある) • React Dom もかける • https://github.com/necolas/react-native-web React Native for Web とは 20
import React from 'react'; import { View, Text, StyleSheet }
from 'react-native'; export default class WebApp extends React.Component { render() { return ( <View> <Text style={{fontSize: 20, color: 'blue'}}>ネイティブ</Text> <div style={{fontSize: 20, color: 'red'}}>ウェブ</div> </View> ); } } React Dom と React Native が共存できる 21
export default class App extends React.Component { render() { if
(Platform.OS == 'web') { return ( <View style={styles.container}> <div style={{fontSize: 20, color: 'red'}}>ウェブ</div> </View> ); } else { return ( <View style={styles.container}> <Text style={{fontSize: 20, color: 'blue'}}>ネイティブ</Text> </View> ); } } } Platformによって出し分ければよさそう 22
23
結構よさそう 24
• 純粋な React Native のプロジェクトに後から入れることができる • 複数のプロジェクトを飼いならさなくてよいから楽 • React Native
コンポーネントを割といい感じに変換してくれる ◦ Vibration API も変換できていたりする ◦ 挙動が見れる:http://necolas.github.io/react-native-web/examples/ • Web 用にトランスパイルできなくても、 Web 用の実装をして出し分けることができる React Native for Web 25
26 試したこと 1. React / React Native を同じリポジトリに置いてデータ周りを共通化する 2. React
Native に React Native for Web を導入する 3. ReactXP でプロジェクトを作成する ◦ https://microsoft.github.io/reactxp 4. React Native Dom を導入する ◦ https://github.com/vincentriemer/react-native-dom
まとめ 27
今回のまとめ • React と React Native を使って飼いならす方法は結構ある • 暫定的には React
Native でアプリを開発して React Native for Web で Web を作るの が一番安定そう 28