<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kunihiko Tanaka</title>
    <description>The latest articles on DEV Community by Kunihiko Tanaka (@kunihikot).</description>
    <link>https://dev.to/kunihikot</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F41820%2Fb6d31093-7b84-4cbc-8f75-8fc4ecc5ef2b.jpeg</url>
      <title>DEV Community: Kunihiko Tanaka</title>
      <link>https://dev.to/kunihikot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kunihikot"/>
    <language>en</language>
    <item>
      <title>Next.js 9.0 + TypeScript + redux-observable を試してstarterとして公開した</title>
      <dc:creator>Kunihiko Tanaka</dc:creator>
      <pubDate>Wed, 10 Jul 2019 14:02:02 +0000</pubDate>
      <link>https://dev.to/kunihikot/next-js-9-0-typescript-redux-observable-starter-3dob</link>
      <guid>https://dev.to/kunihikot/next-js-9-0-typescript-redux-observable-starter-3dob</guid>
      <description>&lt;p&gt;Next.js 9.0が出たので試してみたところ、色んなところでハマったのでメモとして残す。&lt;/p&gt;

&lt;h2&gt;
  
  
  redux-observableを導入する段階でハマる
&lt;/h2&gt;

&lt;p&gt;Next.jsでreduxやredux-observableなどを使う時は &lt;code&gt;pages/_app.ts&lt;/code&gt;に処理を書くらしく、いつもと勝手が違ってハマった。&lt;br&gt;
&lt;a href="https://github.com/kirill-konshin/next-redux-wrapper"&gt;next-redux-wrapper&lt;/a&gt;とかあるみたいだけど最終的には使わずに&lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/pages/_app.tsx"&gt;こんな感じ&lt;/a&gt;で書いた。&lt;/p&gt;

&lt;h2&gt;
  
  
  CSSのimportでハマる
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://react.semantic-ui.com/"&gt;Semantic UI React&lt;/a&gt;を導入する際に&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;semantic-ui-css/semantic.min.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;という感じでCSSをimportしようとするとエラーが出てハマった。&lt;br&gt;
Next.jsではwebpack.config.jsで書いているような設定をnext.config.jsに書くらしかったので書いてみたもののサクッと動かなかった。&lt;br&gt;
そして&lt;code&gt;@zeit/next-css&lt;/code&gt;というのを使えば動くという情報を見つけたので試してみたらInvalid Optionなどと言われて動かずさらに検索すると&lt;a href="https://github.com/zeit/next-plugins/issues/392"&gt;関係ありそうなissue&lt;/a&gt;を発見。&lt;br&gt;
ただのworkaroundだけどとりあえず動くようにはなった。&lt;br&gt;
next.config.jsは&lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/next.config.js"&gt;こんな感じ&lt;/a&gt;になっている。&lt;/p&gt;

&lt;h2&gt;
  
  
  Styled Componentsでハマる
&lt;/h2&gt;

&lt;p&gt;ブラウザで画面を開くとconsoleにエラー出ていたので調べたら.babelrcに&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="s2"&gt;"presets"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"next/babel"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="s2"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"styled-components"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;このあたりを追記したら良いとの情報を得て追記したら解決した。&lt;/p&gt;

&lt;h2&gt;
  
  
  開発開始できそうな感じになったので公開した
&lt;/h2&gt;

&lt;p&gt;これでとりあえずエラーも消えて動くようになり開発を始めれそうな状態にはなった。&lt;br&gt;
Next.jsを使わなければ特に気にもならないようなことでハマって結構めんどくさかった。&lt;br&gt;
今後の自分のためと、同じようにNext.js触ろうとしたけど普段通りにいかず面倒くさくて投げた人のために&lt;code&gt;yarn dev&lt;/code&gt;ですぐ開発を始めれるものを残しておいた。&lt;br&gt;
&lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter"&gt;https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter&lt;/a&gt;&lt;br&gt;
Aliasの設定はまだ上手くいっていないし、認証周りもちゃんとできてないのでもうちょっと色々調べる必要がありそう。&lt;br&gt;
Next.js 9は結構いい感じっぽいのでNuxt.js人気に早く追いついて欲しいなー&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>reduxobservable</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Tried &amp; published Next.js 9.0 + TypeScript + redux-observable starter</title>
      <dc:creator>Kunihiko Tanaka</dc:creator>
      <pubDate>Wed, 10 Jul 2019 14:00:11 +0000</pubDate>
      <link>https://dev.to/kunihikot/tried-published-next-js-9-0-typescript-redux-observable-starter-2p33</link>
      <guid>https://dev.to/kunihikot/tried-published-next-js-9-0-typescript-redux-observable-starter-2p33</guid>
      <description>&lt;p&gt;Next.js 9.0 has been released.&lt;br&gt;
I tried it with my usual development libs (redux-observable, styled components, etc...), and I found some gotchas, so I'm writing down this.&lt;/p&gt;

&lt;h2&gt;
  
  
  redux-observable
&lt;/h2&gt;

&lt;p&gt;Using redux-observable with Next.js, we have to put some code to &lt;code&gt;/pages/_app.ts&lt;/code&gt;, and the style is little bit different comparing to pure react development.&lt;br&gt;
There are some libraries that helps it&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kirill-konshin/next-redux-wrapper"&gt;next-redux-wrapper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/bmealhouse/next-redux-saga"&gt;next-redux-saga&lt;/a&gt;
But there are no next-redux-observable or something.
So, eventually I wrote following code.
&lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/pages/_app.tsx"&gt;https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/pages/_app.tsx&lt;/a&gt;
## CSS import
I've tried to use &lt;a href="https://react.semantic-ui.com/"&gt;Semantic UI React&lt;/a&gt;.
But when I write following line, I've got an error.&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;semantic-ui-css/semantic.min.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the Next.js world, we have to create next.config.js instead of webpack.config.js .&lt;br&gt;
So I wrote css-loader settings on it. But it didn't work well.&lt;br&gt;
I googled &amp;amp; found the information about &lt;code&gt;@zeit/next-css&lt;/code&gt;.&lt;br&gt;
But next-css was displaying error like &lt;code&gt;Invalid Option&lt;/code&gt;, so I googled more, and I found &lt;a href="https://github.com/zeit/next-plugins/issues/392"&gt;the issue&lt;/a&gt; of it.&lt;br&gt;
It's just workaround, but worked well.&lt;br&gt;
My next.config.js is following.&lt;br&gt;
&lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/next.config.js"&gt;https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter/blob/master/next.config.js&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Styled Components
&lt;/h2&gt;

&lt;p&gt;There are some errors on the browser console.&lt;br&gt;
I've googled again and some articles saying use &lt;code&gt;.babelrc&lt;/code&gt;.&lt;br&gt;
So I've added &lt;code&gt;.babelrc&lt;/code&gt; and it solved the issue.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"presets": ["next/babel"],
"plugins": ["styled-components"]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Published starter
&lt;/h2&gt;

&lt;p&gt;There are no errors for now.&lt;br&gt;
I felt that using Next.js is little bit different from pure react development, and it made me confusing.&lt;br&gt;
So I published this article &amp;amp; &lt;a href="https://github.com/kunihiko-t/nextjs9-ts-redux-observable-starter"&gt;Next.js 9.0 + TypeScript + redux-observable starter&lt;/a&gt; for me, and the person who is trying Next.js but struggling with errors.&lt;br&gt;
But this repository is still WIP.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Use middleware or something for Authentication&lt;/li&gt;
&lt;li&gt;[ ] Set alias for &lt;code&gt;import { foo } from '~/foo'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Remove 'any' type from epic&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>reduxobservable</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
