<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by OKUSAWA Takashi on Medium]]></title>
        <description><![CDATA[Stories by OKUSAWA Takashi on Medium]]></description>
        <link>https://medium.com/@takashiokusawa?source=rss-6faa2d691ffe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*flTLixAFB1oiY9XR4sxieQ.jpeg</url>
            <title>Stories by OKUSAWA Takashi on Medium</title>
            <link>https://medium.com/@takashiokusawa?source=rss-6faa2d691ffe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 19:21:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@takashiokusawa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ピアッザアプリ大幅アップデートのハマりポイント]]></title>
            <link>https://takashiokusawa.medium.com/%E3%83%94%E3%82%A2%E3%83%83%E3%82%B6%E3%82%A2%E3%83%97%E3%83%AA%E5%A4%A7%E5%B9%85%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%AE%E3%83%8F%E3%83%9E%E3%82%8A%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88-63578b827f72?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/63578b827f72</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Sat, 19 Dec 2020 09:32:50 GMT</pubDate>
            <atom:updated>2020-12-19T09:35:16.161Z</atom:updated>
            <content:encoded><![CDATA[<p>この記事は React Native Advent Calendar 2020 の 19 日目の記事です。</p><h3>はじめに</h3><p>PIAZZA 株式会社でエンジニアをしている奥澤です。 2016 年 10 月に React Native で開発した Android 版 <a href="https://play.google.com/store/apps/details?id=com.piazza_react_native&amp;hl=ja&amp;gl=US">ピアッザ</a> をリリースしました。</p><p>2017 年より、ReactNative の Advent Calendar に参加させて頂いております。</p><ul><li><a href="https://medium.com/@takashiokusawa/reactnative%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E9%96%8B%E7%99%BA%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E8%A9%B1-c155075fa276">2017</a></li><li><a href="https://medium.com/@takashiokusawa/react-native%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9%E3%81%8B%E3%82%892%E5%B9%B4%E3%81%8C%E9%81%8E%E3%81%8E%E3%81%9F%E8%A9%B1-d01197ff0c79">2018</a></li><li><a href="https://medium.com/@takashiokusawa/react-native-%E3%81%A7%E3%81%AE-android-%E3%82%A2%E3%83%97%E3%83%AA-%E9%96%8B%E7%99%BA-2019-%E6%8C%AF%E3%82%8A%E8%BF%94%E3%82%8A%E3%83%A1%E3%83%A2-60650a3b4063">2019</a></li></ul><p>毎年、1 年の振り返りをまとめていたのですが、今回は 12/14 にリリースした大型アップデートで苦労した点を中心に共有したいと思います。</p><p>前提条件として</p><pre>- 開発ターゲットは Android のみ<br>- React 16.8.6<br>- React Native 0.59.9</pre><p>という環境での Tips なので直接役に立つケースは少ないと思いますが、何かのヒントになれば幸いです。 ちなみに、変更箇所は追加/削除合わせて 1 万行超、変更ファイル数は 212 でした。</p><h3>ピアッザ最新版 v4.0 について</h3><p>今まではユーザーが閲覧するエリアを都度切り替えると、アプリ全体がそのエリアの情報のみを表示する、ある意味閉じた環境でしたが、v4.0 ではいわゆるニュースアプリのような UI になり、トップタブでエリアを横断した情報が閲覧でき、タブによって複数のエリアの切り替えがスムーズにできるようになりました。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*8GstH0m6SB8-4GJo-IvdPw.png" /></figure><p>この UI を実現するにあたり、前提条件の中でハマった点が以下になります。</p><h3>react-native-scrollable-tabview</h3><p>タブの表示には、 <a href="https://github.com/ptomasroos/react-native-scrollable-tab-view">react-native-scrollab-tabview</a> を使っています。今回のアップデート以前から他の画面にで利用させてもらってますが、ニュースアプリ風 UI を実現する上で、2 箇所ハマりポイントがありました。</p><h3>タブの並び替えによって参照先が変わると反映されない</h3><p>react-native-scrollable-tabview では内部で tabLabel によって viepager の参照先を管理していますが、tabLabel が動的に変わっても、参照先はかわりません。なので初回描画時の参照先をずっと参照しつづけるため、タブの並び替えの対応ができません。</p><p>今回は、闇に葬られていたこちらの <a href="https://github.com/MoonHoo/react-native-scrollable-tab-view/commit/9c0aa419e71509db7c001dbe10336316d6583b87">PR</a> を使わせて頂きました。(ローカルでこちらの commit の patch を作って対応)</p><h3>タブのラベル名を変更後に、タブ全体のサイズが更新されない</h3><p>タブのラベルに各エリアの新着投稿件数を(1)みたいに表示していて、タブを開くときに新着数を消すと、タブ全体の width が更新されないため、隙間ができたり逆に新着投稿数を後から追加すると初期化時の width より大きくなりタブが表示されなかったりします。 こちらも、↑ の patch によってサイズの再計算が走ることにより解決できました。</p><h3>課題: タブ全体更新時のパフォーマンス</h3><p>タブの削除・並び替え時に、前述の patch を当てた react-native-scrollable-tabview によって更新が走るのですが、更新が終わるまで少し待たされる感じになります。ここは時間がなくてチューニングしきれず…</p><h3>タブの並び替えの実現</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*REn7_kbvaYl_u1MonJUx7A.png" /></figure><p>最初は依存ライブラリが少ない <a href="https://github.com/thomasrovayaz/react-native-draggable-dynamic-flatlist">react-native-draggable-dynamic-flatlist</a> で実装したのですが、どうにもパフォーマンスが悪く納得できる挙動でなかったため、リリース直前に <a href="https://github.com/computerjazz/react-native-draggable-flatlist">react-native-draggable-flatlist</a> に乗り換えました。ただ、前提条件にあるように、ReactNative 0.59.9 利用のため導入にかなり苦労しました…</p><p>結論から先に書くと今回導入した各ライブラリの version は</p><pre>&quot;react-native-draggable-flatlist&quot;: &quot;^2.5.1&quot;,<br>&quot;react-native-gesture-handler&quot;: &quot;^1.3.0&quot;,<br>&quot;react-native-reanimated&quot;: &quot;^1.2.0&quot;,</pre><p>です。</p><p>各ライブラリ導入時のハマりポイント</p><ul><li><a href="https://majintools.com/2019/08/06/dexfile/">https://majintools.com/2019/08/06/dexfile/</a></li><li><a href="https://github.com/computerjazz/react-native-draggable-flatlist/issues/100">https://github.com/computerjazz/react-native-draggable-flatlist/issues/100</a></li><li><a href="https://github.com/computerjazz/react-native-draggable-flatlist/issues/161">https://github.com/computerjazz/react-native-draggable-flatlist/issues/161</a></li></ul><p>今回、本来は Modal 内で react-native-draggable-flatlist を使いたかったのですが、最新版を入れる事ができないため断念しました。最新版でなくても、0.60 以降でないととにかく今は厳しいですね…</p><h3>パフォーマンス</h3><p>タブを切り替えにより各エリアのタイムラインが表示されるのですが、初回実装時はタブを切り替える毎に 10 数秒(しかも開いたタブが増える事に時間が長くなる…)という極めて動作が重い状態でした。こちら原因突き止めるのに 3 日間かかったのですが理由としては、React/Redux/Immutable.js をきちんと理解していなかった事が原因です。4 年半使ってるのに情けない。。。</p><p>詳細は、各 Screen の mapStateToProps (これも早く hook 化したい) で</p><pre>{<br>    article: state.article.toJS()<br>}</pre><p>みたいに横着していたせいです。今までのアプリではこれでも問題ありませんでしたが、今回の実装では、例えばあるエリアのタブが ↑ のように article を参照してる状態で、他のエリアタブで article を fetch すると全てのタブで更新が走ってしまいます。なので、タブを開く度に激重になるという顛末でした。。まあ、自分が悪いんですが、このあたり気にしなくてもパフォーマンス問題ないような React/ReactNative/Redux になっていってほしいな…という気持ちもあります。</p><p>↑ の toJS() 抹殺の他に、useMemo, useCallBack も積極的に利用することにより、最終的にはそこそこ納得の行くパフォーマンスとなりました。</p><h3>その他</h3><h3>react-native-image-croppicker</h3><p>各種ライブラリを入れ直してるときに、うっかり最新版をいれたらエラーに</p><p><a href="https://github.com/ivpusic/react-native-image-crop-picker/issues/1304#issuecomment-639246786">https://github.com/ivpusic/react-native-image-crop-picker/issues/1304#issuecomment-639246786</a></p><h3>まとめ</h3><p>React Native 0.60 以降に早くアップデートせねば！！！！！</p><h3>最後に</h3><p><a href="https://www.wantedly.com/projects/352209">PIAZZA 株式会社ではエンジニアを絶賛募集中です！！！</a></p><p>↑の募集はサーバーサイドですが、私と一緒に ReactNative で Android アプリを開発して頂ける方も、めっちゃ募集中です！！！</p><p>一人で作るのは、さすがに限界になってきたので切実です。。。</p><p>React Native Advent Calendar 2020 20日目は <a href="https://qiita.com/eishis">@eishis</a> さんです！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63578b827f72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native での Android アプリ 開発 2019 振り返りメモ]]></title>
            <link>https://takashiokusawa.medium.com/react-native-%E3%81%A7%E3%81%AE-android-%E3%82%A2%E3%83%97%E3%83%AA-%E9%96%8B%E7%99%BA-2019-%E6%8C%AF%E3%82%8A%E8%BF%94%E3%82%8A%E3%83%A1%E3%83%A2-60650a3b4063?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/60650a3b4063</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Sat, 07 Dec 2019 04:44:04 GMT</pubDate>
            <atom:updated>2019-12-07T04:46:48.850Z</atom:updated>
            <content:encoded><![CDATA[<p>この記事は<a href="https://qiita.com/advent-calendar/2019/react-native">React Native Advent Calendar</a> 2019 の 7 日目の記事です。</p><h3>はじめに</h3><p>PIAZZA 株式会社でエンジニアをしている奥澤です。 2016 年 10 月に React Native で開発した<a href="https://play.google.com/store/apps/details?id=com.piazza_react_native&amp;hl=ja">Android 版 PIAZZA(ピアッツァ)</a> をリリースしました。</p><p><a href="https://medium.com/@takashiokusawa/reactnative%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E9%96%8B%E7%99%BA%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E8%A9%B1-c155075fa276">一昨年</a> 、<a href="https://medium.com/@takashiokusawa/react-native%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9%E3%81%8B%E3%82%892%E5%B9%B4%E3%81%8C%E9%81%8E%E3%81%8E%E3%81%9F%E8%A9%B1-d01197ff0c79">昨年</a>、に続いて 1 年の開発の振り返りをしたいと思います。</p><p>一見、自分には関係ない…みたいな所も、何かトラブルがあったときの手がかりになりうる事が結構あると思うので、何かのお役に立てれば幸いです。</p><h3>リリース回数</h3><p>2018/12〜2019/11 の 1 年間で、24 回でした。昨年は 18 回だったので結構増えました。 0.59.9 へのアップデートを他のメンバーが手伝ってくれたのが大きかったです。</p><h3>targetSdkVersion 26 での push 通知対応</h3><p>使用ライブラリは <a href="https://github.com/evollu/react-native-fcm">react-native-fcm</a> 当時最新版を入れようとして、ビルドエラーが発生したが、<a href="https://github.com/evollu/react-native-fcm/issues/1062#issuecomment-436160975">こちら</a>で解決。サーバー側で channel を送信するように追加。</p><h3>スプラッシュ表示ライブラリの変更</h3><p>スプラッシュ画像の 9patch 化の際に、当時使用していた<a href="https://github.com/mehcode/rn-splash-screen">rn-splash-screen</a>では上手くいかなかったので、<a href="https://github.com/crazycodeboy/react-native-splash-screen">react-native-splash-screen</a>へ乗り換え。</p><h3>Chrome Custom Tabs 導入</h3><p>WebView が RN 本体から切り離されるのを機に。<a href="https://github.com/droibit/react-native-custom-tabs">react-native-custom-tabs</a>を導入。</p><h3>redux-persist 導入</h3><p>immutable.js を使ってたため、手間取りました。<a href="https://twitter.com/tak603/status/1090631425353633792">https://twitter.com/tak603/status/1090631425353633792</a></p><h3>react-native-calendars 導入</h3><p>イベントカレンダー機能の追加時に、<a href="https://github.com/wix/react-native-calendars">react-native-calendars</a>を試したが、機能がイマイチ足りなかったので<a href="https://github.com/okusawa/react-native-calendars/tree/feature/jp_holiday">fork</a>して使ってます。</p><ul><li>土日や祝日の色を変更可</li><li>CalendarList に onScrollBeginDrag/onScrollEndDrag/onMomentumScrollBegin/onMomentumScrollEnd をセットできるように</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*dSj8hKQF5guECMDialWK3w.png" /></figure><p>祝日の判定は、<a href="https://github.com/horikeso/japanese-holidays">こちら</a>のコードを使わせてもらってます。</p><h3>0.59.9 へのアップデートと、64bit apk 対応</h3><p>Reactotron の update 時にハマり。 createStore に Reactotron.createEnhancer()を追加で解決。</p><h3>Share.share()</h3><p><a href="https://facebook.github.io/react-native/docs/share">Share · React Native</a></p><p>投稿やアプリのシェアを独自実していたものを、標準のものに置き換え。 こんな便利なのがあるの知らなかった…</p><h3>targetSdkVersion 28 対応</h3><p>※いずれも 2019/10 月時点での対応です。</p><p>使用してる native module に warning が出るので以下の対応。</p><ul><li>AndroidManifest.xml に android:usesCleartextTraffic=”true”</li><li>react-native-fbsdk 最新版を試すもエラー。<a href="https://github.com/facebook/react-native-fbsdk/issues/620#issuecomment-521990202">こちら</a>で解決。</li><li>react-native-custom-tabs は<a href="https://github.com/cihanjotform/react-native-custom-tabs#develop">こちら</a>の fork 版を。</li><li>react-native-photo-view は<a href="https://github.com/thanhcuong1990/react-native-photo-view#master">こちら</a>の fork 版を。</li><li>react-native-shared-preferences は latest で問題なし。</li><li>react-native-splash-screen v3.2.0 で問題なし。</li></ul><h3>Android X 対応でビルドが通らなくなる</h3><p><a href="https://twitter.com/tak603/status/1140895933892136960">https://twitter.com/tak603/status/1140895933892136960</a></p><p>年に何度か発生する、突然ビルドが通らなくなる問題。 このとき、真剣に Expo への移行を検討しました。</p><h3>lineHeight の設定</h3><p>テキストを複数行表示する場合、lineHeight を設定していないと、最終行が少し欠けて表示される事が多くなった。 以前は無かったような気がするが…</p><h3>rn-fetch-blob</h3><p>画像保存後に、ギャラリーへ飛ばせるようにしてる部分が warning がでて動かなくなっていた。</p><p>原因は<a href="https://github.com/joltup/rn-fetch-blob/pull/317">こちら</a>。 RN 0.60.0 未満は v0.10.15 を使う必要があり、そちらには上記修正は適応されていない。 とりあえず patch 作って対処。</p><h3>FlatList を一部画面に導入</h3><p>2016 年 7 月に開発をはじめたときは、ScrollView/ListView の使い勝手がイマイチだったので、ScrollView をベースにした自作 ScrollView クラスをほとんどの画面で使いまわしていたが、新しく作る画面で FlatList を試したところ、とても使い勝手が良かったので、感動した。もっと早く使いはじめていれば…</p><h3>Google Play の審査</h3><p>審査に時間がかかるようになってから初のアップデートでは、公開まで 3 時間ほどかかったが、その後は大体 30 分以内に公開されるようになった。</p><h3>まとめ</h3><p>2019 年も RN 本体やライブラリのアップデートで時間を取られることが多かったです。 特に、<a href="https://twitter.com/tak603/status/1140895933892136960">こちら</a>のビルドエラー発生時は、当時 Expo への移行を検討してる時期だったので、Expo へ完全移行するしかないと思いました。ですが、RN 自体の最近のアップデート状況を見ると react-native-unimodules を入れれば十分かな？と思います。</p><p>React を触りはじめて 4 年以上、ReactNative を触りはじめて 3 年半以上経ちますが、どちらも進化が止まらないので、楽しく開発できてます。2020 年は react-native-unimodules を導入したり、既存画面を Hooks で置き換えつつリファクタしたり、やりたいことはたくさんあります！</p><p>最後に、<a href="https://www.wantedly.com/projects/352209">PIAZZA 株式会社はエンジニアを絶賛募集中です！</a></p><p><a href="https://prtimes.jp/main/html/rd/p/000000031.000016981.html">シリーズ A 資金調達が終わり</a>会社もサービスもどんどんスケールさせていくので、興味がある方はお気軽にメッセージ下さい！！</p><p>React Native Advent Calendar 2019 8 日目は <a href="https://qiita.com/pside">@pside</a> さんです！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60650a3b4063" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Nativeで地域SNSアプリを開発して2年が過ぎた]]></title>
            <link>https://takashiokusawa.medium.com/react-native%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9%E3%81%8B%E3%82%892%E5%B9%B4%E3%81%8C%E9%81%8E%E3%81%8E%E3%81%9F%E8%A9%B1-d01197ff0c79?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d01197ff0c79</guid>
            <category><![CDATA[piazza]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Mon, 03 Dec 2018 15:00:36 GMT</pubDate>
            <atom:updated>2018-12-03T15:45:35.869Z</atom:updated>
            <content:encoded><![CDATA[<p>この記事は<a href="https://qiita.com/advent-calendar/2018/react-native">React Native Advent Calendar 2018 3日目</a>です。</p><p><a href="https://www.lp.piazza-life.com/">PIAZZA</a>という<a href="https://play.google.com/store/apps/details?id=com.piazza_react_native&amp;hl=ja">地域SNSのandroidアプリ</a>をReact Nativeで開発しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9YCoFDLb8iowy8bSVmnFg.png" /></figure><p><a href="https://medium.com/@takashiokusawa/reactnative%E3%81%A7%E5%9C%B0%E5%9F%9Fsns%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E9%96%8B%E7%99%BA%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E8%A9%B1-c155075fa276">昨年の投稿</a>から1年間の開発メモというような位置づけです。</p><h3>開発について</h3><ul><li>ReactNativeによるandroidアプリの開発。</li><li>開発メンバーは自分ひとり。</li><li>apiも自分で書く。</li><li>コード規模: 約26000行</li></ul><h3>この1年</h3><ul><li>リリース回数: 18回(2017/12〜2018/11)</li></ul><p>以下、機能追加やupdate時のハマり等を項目毎に。</p><h3><a href="https://github.com/alwx/react-native-photo-view">react-native-photo-view</a></h3><p>画像の拡縮に<a href="https://github.com/Anthonyzou/react-native-image-zoom">react-native-image-zoom</a>を使っていたが、ある不具合によりreact-native-fcmのupdateが必要 → sdkやbuildtools等のupdateが必要 → 他のnative moduleがビルドエラー → エラーになるnative moduleをupdateしようとしたらメンテされていない。</p><p>という玉突き事故により、react-native-photo-viewへ移行した。<br>移行作業自体は一瞬で終わったが、<strong>移行するに至った経緯に課題を感じた。</strong></p><h3>テキストをコピペ</h3><p><a href="https://facebook.github.io/react-native/docs/text#selectable">Textコンポーネントにselectableをセットするだけ。</a></p><h3>react-native-fcmでlarge_iconが表示されない</h3><p><a href="https://github.com/evollu/react-native-fcm/issues/270">updateにより解決</a></p><h3>Android8.0で通知アイコンが正しく表示されない</h3><p><a href="https://stackoverflow.com/questions/49348904/android-fcm-push-notification-icon-not-showing-in-oreo-devices">firebase-messaging:12.0.0へのupdateで解決</a></p><p>この変更に伴い、react-native-fcmのupdateが必要になり、さらに他のnative moduleもビルドエラーが発生したためupdateが必要になった。</p><h3>2018/05/16〜17頃に起きたビルドエラー</h3><h3>原因</h3><p><a href="https://github.com/facebook/react-native/issues/19259">https://github.com/facebook/react-native/issues/19259</a> <a href="https://github.com/facebook/react-native/issues/13094#issuecomment-389568018">https://github.com/facebook/react-native/issues/13094#issuecomment-389568018</a></p><h3>暫定対応</h3><p><a href="https://github.com/facebook/react-native/issues/19272#issuecomment-389405958">https://github.com/facebook/react-native/issues/19272#issuecomment-389405958</a></p><p>2018/05/18には解決していた。これは最初本当に原因がわからなくて途方に暮れた。</p><h3>okhttpが古いverのため、特定のurlを読み込むと落ちる</h3><p>投稿やコメント等にURLリンクが含まれる場合に、プレビューをするように機能追加した。<br>機能の実装については今後別記事で。ここではこの機能を使用時にハマった不具合にについて。</p><p>XMLHttpRequestでプレビューするページへアクセスした際に、特定のurlで落ちる現象が発生した。<br><a href="https://github.com/facebook/react-native/issues/11680">ReactNativeで使われているokhttpが新しくなれば解決するようだ</a></p><p>すぐに、ReactNativeのupdateをすることができなかったため、エラーが発生するurlを内部でブラックリストして持って、アクセスしないようにするしかなかった。</p><h3>画像保存</h3><p><a href="https://github.com/joltup/rn-fetch-blob">rn-fetch-blob</a>を使って、投稿やコメントの画像を保存できる機能を追加した。詳細については今度別投稿にまとめたい。</p><h3>項目を編集後、保存せずに遷移しようとした際にアラート</h3><p>プロフィール編集画面で、項目を変更した後に保存せずに前の画面に戻ろうとするときに、アラートを出すようにした。PIAZZAの場合はandroidの戻るボタンとヘッダにあるボタンと2つのボタンで戻ることが可能なので、それぞれに処理を追加した。</p><p>androidの戻るボタンへのハンドリングは以下のような感じ。</p><pre>componentDidMount() {<br>  BackHandler.addEventListener(&#39;hardwareBackPress&#39;, this.onBackAndroid);<br>}</pre><pre>componentWillUnmount() {<br>  BackHandler.removeEventListener(&#39;hardwareBackPress&#39;, this.onBackAndroid);<br>}</pre><pre>onBackAndroid() {<br>  // 他の画面での暴発を防ぐ<br>  const { name } = this.props.root.scene; // rootには現在のsceneをセットしている<br>  if (name.match(/この画面のscreenName/)) {<br>    // needToSaveは項目が編集されたかどうかが入っている<br>    const { needToSave } = this.props;<br>    if (needToSave) { <br>     // アラート表示<br>     return true;<br>    }<br>  }<br>  return Actions.pop(); // routerは react-native-router-flux<br>}</pre><h3>animation</h3><p><a href="https://qiita.com/nakanishy/items/9b8bb8fe5bee6a6c677b">こちら</a>で紹介されていた、opacityのanimationをいくつかの画面、componentで使わせていただきました。</p><h3>react-native-fbsdk@0.7.0</h3><p>react-native-fbsdkは結構な問題児。。<br>v0.7.0を使う際に遭遇したエラー <a href="https://github.com/facebook/react-native/issues/18225">https://github.com/facebook/react-native/issues/18225</a> 最終的にはissueにあったコメントにある<a href="https://github.com/javadoffuad/react-native-facebook-login">sample project</a>を参考にビルド設定を変えたら動いた。</p><h3><a href="https://github.com/naoufal/react-native-accordion">react-native-collapsible</a>導入</h3><p><a href="https://github.com/oblador/react-native-collapsible">react-native-collapsible</a>の使い勝手がイマイチだったので、乗り換え。</p><h3>0.45.1 → 0.57.2 へのupdate</h3><p>絶賛対応中。現在0.49.5の確認中。完了したら別記事にまとめたい。先は長い…</p><h3>今後の課題</h3><h3>依存ライブラリを減らす</h3><p>ReactNativeに限らずだが、使用ライブラリが少ないほど本体のversion upの手間が減る。<br>native moduleはある程度仕方無いが、<strong>簡単なUIは外部ライブラリに頼らず自作したほうが、長期的には手間が少ない。</strong></p><h3>react-native-router-flux v4への移行</h3><p>ReactNative本体のupdateが終わったら、v4へ移行予定。 v3系も実は更新されていて、<a href="https://www.npmjs.com/package/react-native-router-flux/v/3.45.0">v3.45.0</a>が最新版。</p><h3>react-native-firebaseへの移行</h3><p>react-native-fcmの作者がreact-native-firebaseを勧めている <a href="https://github.com/evollu/react-native-fcm">https://github.com/evollu/react-native-fcm</a></p><h3>FlatListへの移行</h3><p><a href="https://github.com/soldotno/react-native-lazyload-deux">react-native-lazyload-deux</a>(react-native-lazyloadがメンテされていないので、forkされたほうを使っているが、FlatListを使うべき。</p><h3>Stateless Functional Componentを使う</h3><p>なるべくSFCを使うようにして、React Hooksに備える。</p><h3>TypeScript化</h3><p>今後に備えてTS化の流れに乗って行ったほうがいい気がするが、どうだろう…</p><h3>終わりに</h3><p><strong>課題やトラブルをどう解決したか</strong>をアウトプットする事が多いため、読んでる方にはReactNativeに対してネガティブな印象を抱いてしまうと思うのですが、私が2年半以上開発に使ってる感想としては、満足度は高いです。</p><ul><li>AndroidStudioを起動せずに、好きなエディタと</li><li>使い慣れた React/Redux で</li><li>Hot Reloadによる効率のいいandroidアプリ開発ができる</li></ul><p>あと、私の場合はandroidアプリのみの開発に使用してるので、ios/android両方を開発するよりは、トラブルは少ないので、その分ストレスも少ない…かも。</p><p>理不尽なトラブルもありますが、大抵世界中の優秀なエンジニアが解決してくれています。<br>react-nativeのissueやStack Oerflowに偉大な先人達が解決策やヒントを残してくれています。<br>何回かトラブルを経験すると、なんとなくどこがネックなのか想像がつきやすくなります。 この投稿も、React Naitveでandroidアプリを開発する方の助けに少しでもなれば幸いです。</p><p>個人的には、今後新規でアプリを作る際には、是非Expoを試してみたいです。 React Native Advent Calendar 2018ではExpoの話題が多そうなので、期待しています。</p><p>最後に、<a href="https://www.wantedly.com/projects/234799">PIAZZA株式会社ではエンジニアを絶賛募集中です！</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d01197ff0c79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native at Airbnbを読んだ感想とメモ]]></title>
            <link>https://takashiokusawa.medium.com/react-native-at-airbnb-%E3%82%92-%E8%AA%AD%E3%82%93%E3%81%A0%E6%84%9F%E6%83%B3%E3%81%A8%E3%83%A1%E3%83%A2-e4ee7c8ad3d6?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4ee7c8ad3d6</guid>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Wed, 20 Jun 2018 03:54:22 GMT</pubDate>
            <atom:updated>2018-06-20T03:54:22.705Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/airbnb-engineering/react-native-at-airbnb-f95aa460be1c">https://medium.com/airbnb-engineering/react-native-at-airbnb-f95aa460be1c</a></p><h3><a href="https://medium.com/airbnb-engineering/react-native-at-airbnb-the-technology-dafd0b43838">part2</a></h3><ul><li>reduxの学習曲線が緩やか</li><li>RNをforkして使っていた。2年間でそこへ約50commit。結果upgradeが苦しくなる。</li><li>型についてはflowはエラーメッセージがわかりにくい、TypeScriptは調査中。</li><li>型が無いとリファクタリングが辛い。</li><li>androidがJSCoreを持っていないため、ios/androidで動作に差異があるケースがあった。</li><li>マルチプラットフォームに対応したOSSは全てのプラットフォームに同等の知識がある人間が作成してるわけではない。(よって不具合も多い。)</li><li>クラッシュレポートにBugsnagを使用。</li><li>クラッシュ時に、ReactNativeとネイティブ間でスタックトレースがジャンプできなくてデバッグが困難。</li><li>Native Bridgeでjsから整数がくる際、多くの場合は文字列として渡ってくる。iosは単なるエラーでもandroidでクラッシュする場合もある。</li><li>ランタイムの初期化に時間がかかる。</li><li>最初のレンダリングに時間がかかるので、android/ios双方別の方法で対処をいれている。</li><li>アプリサイズの増大も無視できないレベルである。</li><li>FlatListはAndroidのRecyclerViewやiOSのUICollectionViewには及ばない。</li><li>RN本体が一時期RN0.16betaを使用していたため、upgradeできなかった。このため、インフラストラクチャに大きな損害があった。</li></ul><h3><a href="https://medium.com/airbnb-engineering/building-a-cross-platform-mobile-team-3e1837b40a88">part3</a></h3><ul><li>ios/android/react全てに優秀なエンジニアはまれ。よってそのプラットフォームに経験の浅いエンジニアがデバッグする場合、困難な場合がある。</li><li>Airbnb = 100% ReactNativeというイメージのせいで、ios/androidのネイティブエンジニアが応募をためらう結果となった。</li><li>ハイブリッドアプリ開発は難しい。stateの共用、チームの分割/運用、テスト、リソースの雇用/運用…</li><li>ReactNative/ios/androidの3つの開発環境を学習し、全て最新を維持するのは時間がかかる。</li><li>多くのエンジニアはどちらか1つのプラットフォームをメインに開発する。だが、それだとQAで問題/遅延が発生するため、間違いだった。</li><li>コードベースがネイティブとReact Nativeに分割されると、コードが断片化する。</li><li>ios/anroidに比べると、教育/トレーニング(のリソースが限られているため)に投資が必要</li></ul><h3><a href="https://medium.com/airbnb-engineering/sunsetting-react-native-1868ba28e30a">part4</a></h3><ul><li>3つのプラットフォームでのコードの共有が思ったほどうまくいかなかった。</li><li>ビルド時間は劇的に向上するものの、デバッグ等で時間がかかってしまう。</li><li>今年末までに、トラフィックの多い画面の大半をnativeへ移行する。</li></ul><h3><a href="https://medium.com/airbnb-engineering/whats-next-for-mobile-at-airbnb-5e71618576ab">part5</a></h3><ul><li>Server-Driven Rendering の具体的な仕組みが気になる。画面(UI)の定義をクライアントに送って画面生成かな？</li><li>状態を維持しつつjson駆動の画面遷移を実現。</li><li><a href="https://github.com/airbnb/Lona/">Lona</a>を使用した完全なカスタムコンポーネント。</li><li><a href="https://github.com/airbnb/epoxy">Epoxy</a>をandroid, ios双方で使用している。</li><li>MvRxという新しいフレームワークを使っている。今後オープンソースを計画中。</li><li>iosも同様のフレームワークに取り組んでいる。</li><li>ビルド速度の改善についても、色々やって目処がついている。(良くわからないが、依存関係整理してプロジェクト分けてビルドしてる？)</li></ul><h3>感想</h3><p>非常に読み応えのある内容だった。</p><p>ReactNativeへの印象は 個人によってもそうだが、会社(のステージ)や事業によっても当然変わる。また、使い方(web含めたマルチ, ios/adnroidマルチ, ios or android)によっても変わる。</p><p>自分の場合は、以下の要件が重なってRNを使うに至った。</p><ul><li>AndroidStudioを使いたくない(emacsから出たくない)</li><li>ホットリロードが最高</li><li>Reactを使ったことがあった</li><li>自分ひとりで開発/自分で技術を選べた</li><li>RN自体の仕組みに興味があり、使ってみたかった</li><li>androidのみの使用のため、クロスプラットフォームを考えないで良い</li></ul><p>今後社内の状況が変わり、プロダクトに要求される内容が変われば、ネイティブで作り直したほうがいいと思う時が来るかもしれないし、来ないかもしれない。</p><p>airbnbのようにインフラストラクチャ部門が自分が感じた不満を解消してくれるなら、AndroidStudioで開発してもいい…かもしれない。</p><p>採用については、なるほどと思った。確かにRNのイメージが強すぎる場所にわざわざios/androidネイティブが強い/好きなエンジニアは応募しないだろう。</p><p>先の事はどうなるかわからないが、自分が好きで選んだ技術なので自分が責任を取れる間は使い続けたい。 RN触りはじめて2年半が過ぎたが、最近だとRNDomに興奮し、またRN自体への興味もまだ尽きない。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4ee7c8ad3d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[react-native-domを試す]]></title>
            <link>https://takashiokusawa.medium.com/react-native-dom%E3%82%92%E8%A9%A6%E3%81%99-6843a0e10cbc?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/6843a0e10cbc</guid>
            <category><![CDATA[react-native-dom]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Wed, 23 May 2018 16:42:19 GMT</pubDate>
            <atom:updated>2018-05-23T16:46:25.492Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://rndom-movie-demo.now.sh/">デモ</a>を見て、どうしても試したくなったので、<a href="https://play.google.com/store/apps/details?id=com.piazza_react_native">PIAZZA</a>で試してみた。</p><p>PIAZZAのRN verは0.45.1のため、raect-native-domを直接入れる事はできなかった。 そこで、新規プロジェクトを作成して必要最小限のコードとデータを持ってきてタイムラインの表示ができるまでを試してみた。</p><p>作業時間は、2–3時間ほど。</p><h3>環境</h3><p>とりあえず動作確認できたものだけ抜粋</p><pre>&quot;dependencies&quot;: {<br>     &quot;immutable&quot;: &quot;^3.8.2&quot;,<br>     &quot;react&quot;: &quot;16.3.1&quot;,<br>     &quot;react-native&quot;: &quot;0.55.4&quot;,<br>     &quot;react-native-animatable&quot;: &quot;^1.2.4&quot;,<br>     &quot;react-native-dom&quot;: &quot;0.1.1&quot;,<br>     &quot;react-native-router-flux&quot;: &quot;^4.0.0-beta.31&quot;,<br>     &quot;react-native-scrollable-tab-view&quot;: &quot;^0.8.0&quot;,<br>     &quot;react-redux&quot;: &quot;^5.0.7&quot;,<br>     &quot;redux&quot;: &quot;^4.0.0&quot;,<br>     &quot;redux-saga&quot;: &quot;^0.16.0&quot;,<br>     &quot;superagent&quot;: &quot;^3.8.3&quot;,<br>   },<br>   &quot;devDependencies&quot;: {<br>     &quot;babel-jest&quot;: &quot;22.4.4&quot;,<br>     &quot;babel-preset-react-native&quot;: &quot;4.0.0&quot;,<br>     &quot;jest&quot;: &quot;22.4.4&quot;,<br>     &quot;react-test-renderer&quot;: &quot;16.3.1&quot;,<br>     &quot;reactotron-react-native&quot;: &quot;^1.14.0&quot;,<br>     &quot;reactotron-redux&quot;: &quot;^1.13.0&quot;,<br>     &quot;rnpm-plugin-dom&quot;: &quot;^0.1.1&quot;<br>   },</pre><h3>プロジェクト作成</h3><p>Getting Startedの通りにやればいい。特に問題無し。</p><h3>移植</h3><p>新規作成したプロジェクトへ既存プロジェクトから最小限のコードを持ってきて、ちょっとずつエラーを解決していくだけ。。</p><h3>デバッグ</h3><p>reactotronが普通に使えたので問題無し。</p><h3>ライブラリ</h3><h3>ract-native-router-flux</h3><p>v4はじめて使ったが、Scene, tab共に問題無く動作。</p><h3>redux/redux-saga</h3><p>こちらも問題無し。</p><h3>react-native-scrollable-tab-view</h3><ul><li>Button.ios.jsやButton.android.jsとPlatoformでファイルが別れていたため、Button.dom.jsを作成した。(Button.ios.jsをcopy)</li><li>Platform.OS === ‘ios’ を Platform.OS !== ‘android’ に変えてやると動く。だが表示は崩れる。</li></ul><h3>react-native-animatable</h3><p>動いた。</p><h3>通信</h3><h3>rails4</h3><p><a href="https://qiita.com/tridentfield/items/290e21f04aed587afad2">こちら</a>を参考にクロスドメイン対応</p><h3>クライアント</h3><p>superagentでうまく行かなかったのでfetchへ変更。</p><pre>fetch(url, { credentials: &#39;omit&#39; })<br>                           .then(res =&gt; res.json());</pre><h3>メモ</h3><ul><li>modal未対応</li><li>Text: numberOfLinesは未対応</li><li>スクリーンサイズを見て座標を調整してる箇所が一部ずれた。サイズ取得のタイミングの問題だろうか。</li><li>スクロール位置を見てfetchする処理が上手く動かなかった。スクロール時のイベントが上手く取れてないか。実装されてないか。(movieデモは問題無さそうだが…)</li><li>ScrollViewの引っ張って更新も動かない。引っ張れない。</li><li>Text: allowFontScaling={false} 表示が崩れる。 </li></ul><h3>感想</h3><ul><li>既存プロジェクトはmovieデモのように動かすのは現時点では一筋縄ではいかない。</li><li>最初、ブラウザで赤いエラー画面が出るだけでもテンションがあがる。</li><li>完成度が高まれば、既存プロジェクトを簡単な修正のみでwebで動かせるようになるのではないだろうか。期待が持てる。</li><li>引き続き注目していきたい。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*KQ5RMKsLS1FQJOQH3iWESg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6843a0e10cbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ReactNative: AndroidStudio3への移行]]></title>
            <link>https://takashiokusawa.medium.com/reactnative-androidstudio3-%E3%81%B8%E3%81%AE-%E7%A7%BB%E8%A1%8C-8a34e16f6806?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a34e16f6806</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Mon, 07 May 2018 14:41:26 GMT</pubDate>
            <atom:updated>2018-05-07T14:41:26.798Z</atom:updated>
            <content:encoded><![CDATA[<p>AndroidStudio 2.3.1 → 3.1.2 へ移行した際の作業メモ。</p><p>AndroidStudioのみのupdateであれば、自分の環境では特に問題発生せず。 ただ、この機会にgradleも最新版にしてみようとしたらいくつか問題が発生した。</p><h3>gradle 3.1.0以降は、Build Tools 27.0.3 以降が必要</h3><p><a href="https://developer.android.com/studio/releases/gradle-plugin#3-1-0">https://developer.android.com/studio/releases/gradle-plugin#3-1-0</a></p><h3>buildscriptのrepositoriesにgoogle()を追加しないとビルドエラー</h3><pre>// android/build.gradle<br>buildscript {<br>     repositories {<br>         jcenter()<br>         google()<br>     }<br>     dependencies {<br>         classpath &#39;com.android.tools.build:gradle:3.1.2&#39;</pre><pre>         // NOTE: Do not place your application dependencies here; they belong<br>         // in the individual module build.gradle files<br>         classpath &#39;com.google.gms:google-services:3.0.0&#39;<br>     }<br> }</pre><pre> allprojects {<br>   ...<br> }</pre><h3>リリースビルドでエラー</h3><p><a href="https://github.com/react-navigation/react-navigation/issues/3097">https://github.com/react-navigation/react-navigation/issues/3097</a></p><p>上記の<a href="https://github.com/react-navigation/react-navigation/issues/3097#issuecomment-354511336">コメント</a>の対応でOK。</p><pre>// android/gradle.properties<br>// 以下を追加<br>android.enableAapt2=false</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a34e16f6806" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[react-native-fcmでのpush通知制御(android)]]></title>
            <link>https://takashiokusawa.medium.com/react-native-fcm-%E3%81%A7%E3%81%AEpush%E9%80%9A%E7%9F%A5%E5%88%B6%E5%BE%A1-android-fd8a138342f3?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd8a138342f3</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Sat, 05 May 2018 19:04:49 GMT</pubDate>
            <atom:updated>2018-05-05T19:04:49.470Z</atom:updated>
            <content:encoded><![CDATA[<p>PIAZZAのandroidアプリ初期リリース(2015年10月末)直前に、軽く使い方を調べて何となく使っていたが、画像付きpush通知を実装するにあたり色々調べ直した際の作業メモ。</p><p>もし、これからfcmを使うなら<a href="https://github.com/invertase/react-native-firebase">react-native-firebase</a>のほうが良さそうだ。</p><h3>環境</h3><ul><li>react-native-fcm@14.1.3</li></ul><h3>サーバーサイド(rails)</h3><h3>個別通知</h3><p>AWS SNSからFCMへ通知を送っている。 設定以外で、ハマり/忘れそうなポイントは</p><ul><li>publish::messageに渡すjsonは文字列で無いといけない。 → FCM用のオブジェクトを作ったらto_jsonしたものを文字列として渡す</li></ul><h3>topic通知</h3><p>こちらはfcm.send_to_topicで送るだけ。 送るデータはハッシュのままで問題無い。</p><h3>custom_notification</h3><p><a href="https://github.com/evollu/react-native-fcm/blob/master/Examples/simple-fcm-client/app/App.js">サンプル</a>を見ると画像を送るにはpictureというkeyを設定してあげれば良い。</p><p>ただし、custom_notificationを使ってデータを送る必要がある。 <a href="https://github.com/evollu/react-native-fcm/issues/533">https://github.com/evollu/react-native-fcm/issues/533</a></p><p><a href="https://github.com/evollu/react-native-fcm/issues/533#issuecomment-326590088">コメント</a>にもあるように、通常のnotificationとcustom_notificationを同時に設定してはいけない。</p><p>作業の時に時間食ったミス。 最初以下の形式だったので、単純にnotificationをcustom_notificationに名前変えるだけだろうと思ってしまった。</p><pre>{<br>  notification: { // ここをcustom_notificationに変えて何回も試していた…<br>    body: ...<br>  },<br>  data: { hoge: ... }<br>}</pre><p>こう書かないとダメ</p><pre>{<br>  data: {<br>    custon_notification: {<br>      body: ...,<br>      hoge: ...<br>    }<br>  }<br>}</pre><h3>pictureとbig_textの関係</h3><p>pictureで設定した画像とbig_textで設定したテキストが表示される領域は一緒である。 両方セットした場合はpictureが優先されbig_textは表示されない。</p><h3>クライアント(android)</h3><p>FCMEvent.Notificationでpushされたデータを受け取ってハンドリングする際、payloadでデータを受け取れるが、custom_notificationで来たデータは、<strong>文字列</strong>になる。 よって、payloadにcustom_notificationが入っていたらparseが必要。</p><pre>cost payload = JSON.parse(_payload.custom_notification)</pre><p>通常の形式</p><pre>{<br>  notification: {<br>    body: ...<br>  },<br>  data: { hoge: ... }<br>}</pre><p>の場合はそのまま使えるので注意。サーバーから送るデータの形式は統一したほうがいい。</p><h3>show_in_foregroundの代わりにローカル通知</h3><p>show_in_foreground使うと、アプリがフォアグランドにある場合も通知を表示できる。 だが、全ての通知が表示されるためアプリ側で通知の表示を判定したい場合は使えない。</p><p>そこで、起動中に受け取った通知内容を条件に応じてローカル通知で表示するようにした。</p><p>ファオグラウンドの判定は<a href="https://facebook.github.io/react-native/docs/appstate.html">AppState.currentState</a>を使う。</p><pre>// FCMEvent.Notificationのコールバック<br>pushNotificationAction(_payload: Object) {<br>  let payload = _payload;                                                            <br>  if (payload.custom_notification) {<br>    payload = JSON.parse(payload.custom_notification);<br>  }<br>  // バックグラウンド時には通知は表示されるので、フォアグランド時のみ<br>  const isActive = AppState.currentState === &#39;active&#39;;<br>  if (isActive &amp;&amp; /* 通知を表示したい条件 */) {<br>    FCM.presentLocalNotification(<br>       Object.assign(payload, { show_in_foreground: true })<br>    );<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd8a138342f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduxでreducerを初期化する]]></title>
            <link>https://takashiokusawa.medium.com/redux%E3%81%A7reducer%E3%82%92%E5%88%9D%E6%9C%9F%E5%8C%96%E3%81%99%E3%82%8B-28a65165aef3?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a65165aef3</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Wed, 25 Apr 2018 05:59:28 GMT</pubDate>
            <atom:updated>2023-08-04T00:47:00.328Z</atom:updated>
            <content:encoded><![CDATA[<p>ログアウトした際に、全てのstoreをリセットする方法を探した際のメモ。</p><p><a href="https://stackoverflow.com/questions/35622588/how-to-reset-the-state-of-a-redux-store">https://stackoverflow.com/questions/35622588/how-to-reset-the-state-of-a-redux-store</a></p><p>上記参考に、専用のaction(ROOT_CLEAR)が来たらundefinedを返すようにした。</p><pre>// /reducers/Index.js<br>const reducer = combineReducers({<br>   root,<br>   hoge,<br>   fuga,<br>   ...<br>});</pre><pre>const rootReducer = (state, action) =&gt; {<br>  const flag: boolean = action.type === RootActions.ROOT_CLEAR;<br>  return reducer(flag ? undefined : state, action);<br>};<br>export default rootReducer;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a65165aef3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[emacsでRustを読み書きする環境を整える]]></title>
            <link>https://takashiokusawa.medium.com/emacs%E3%81%A7rust%E3%82%92%E8%AA%AD%E3%81%BF%E6%9B%B8%E3%81%8D%E3%81%99%E3%82%8B%E7%92%B0%E5%A2%83%E3%82%92%E6%95%B4%E3%81%88%E3%82%8B-ecc1982fe3bc?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecc1982fe3bc</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[emacs]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Wed, 18 Apr 2018 15:41:53 GMT</pubDate>
            <atom:updated>2018-04-18T15:41:53.003Z</atom:updated>
            <content:encoded><![CDATA[<p>emacsでRustを読み書きする環境を調べた際のメモ。</p><p>emacsは GNU Emacs 25.2.1 (x86_64-apple-darwin16.5.0) of 2017–05–12</p><p>いくつか調べた結果、<a href="https://qiita.com/AoiMoe/items/a532bb0e554c8060103c">こちら</a>のページに書いてあるpackageの導入と設定で上手く動いた。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nClnZVLwUf2QLL654ivNzA.png" /></figure><p>だが、flycheckで以下のエラーが。</p><pre>Suspicious state from syntax checker rust: Flycheck checker rust returned non-zero exit code 101, but its output contained no errors: error: the option `Z` is only accepted on the nightly compiler</pre><p>上記エラーをそのままググると以下のissueが見つかる。<a href="https://github.com/flycheck/flycheck/issues/1288">https://github.com/flycheck/flycheck/issues/1288</a></p><p>上記issueのコメントに関連するPRがありmergeされてたので、手元のflycheckをupdateしたら解決した。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecc1982fe3bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[react-native-device-infoのupdateでエラー(android)]]></title>
            <link>https://takashiokusawa.medium.com/react-native-device-info%E3%81%AEupdate%E3%81%A7%E3%82%A8%E3%83%A9%E3%83%BC-android-4ce451c473c8?source=rss-6faa2d691ffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ce451c473c8</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[OKUSAWA Takashi]]></dc:creator>
            <pubDate>Tue, 10 Apr 2018 07:36:53 GMT</pubDate>
            <atom:updated>2018-04-10T07:36:53.932Z</atom:updated>
            <content:encoded><![CDATA[<p>react-native-device-info@0.9.5 -&gt; 0.21.5へのupdateでビルドエラーを回避した際の作業メモ。</p><h3>発生したエラー/対策</h3><p>readmeのTroubleshootingに記載あり <a href="https://github.com/rebeccahughes/react-native-device-info#troubleshooting">https://github.com/rebeccahughes/react-native-device-info#troubleshooting</a></p><p>app/build.gradleに以下を追加</p><pre>compile(project(&#39;:react-native-device-info&#39;)) {<br>    exclude group: &#39;com.google.android.gms&#39;<br>}</pre><p>その後、</p><pre>cd android<br>./gradlew clean</pre><p>してから、 react-native run-android を実行する。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ce451c473c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>