<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>React on こぴぺたん ログ</title><link>https://c-a-p-engineer.github.io/categories/react/</link><description>Recent content in React on こぴぺたん ログ</description><generator>Hugo -- gohugo.io</generator><language>ja</language><copyright>&amp;copy;{year}, All Rights Reserved</copyright><lastBuildDate>Fri, 13 May 2022 01:00:00 +0900</lastBuildDate><atom:link href="https://c-a-p-engineer.github.io/categories/react/index.xml" rel="self" type="application/rss+xml"/><item><title>【React + TypeScript】state が反映されないときは useEffect を使用する</title><link>https://c-a-p-engineer.github.io/react-typescript-useeffect/</link><pubDate>Fri, 13 May 2022 01:00:00 +0900</pubDate><atom:modified>Fri, 13 May 2022 01:00:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-typescript-useeffect/</guid><description>&lt;h1 id="react--typescriptstate-が反映されないときは-useeffect-を使用する">【React + TypeScript】state が反映されないときは useEffect を使用する&lt;/h1>
&lt;p>&lt;code>React&lt;/code> で &lt;code>state&lt;/code> が反映されないときは &lt;code>useEffect&lt;/code> を使用する。&lt;/p>
&lt;h2 id="useeffect-を使用する">useEffect を使用する&lt;/h2>
&lt;p>&lt;code>React&lt;/code> の &lt;code>useEffect&lt;/code> を使用する。&lt;br />
&lt;a href="https://ja.reactjs.org/docs/hooks-effect.html" target="_blank" rel="nofollow noopener">副作用フックの利用法 - React&lt;/a>&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category></item><item><title>【React】サブディレクトリでReactを公開する</title><link>https://c-a-p-engineer.github.io/react-subdirectory/</link><pubDate>Sun, 08 May 2022 18:00:00 +0900</pubDate><atom:modified>Sun, 08 May 2022 18:00:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-subdirectory/</guid><description>&lt;h1 id="reactサブディレクトリでreactを公開する">【React】サブディレクトリでReactを公開する&lt;/h1>
&lt;p>Reactをサブディレクトリ上で公開したい場合はビルドしたものを配置するだけではできません。&lt;br />
Reactをサブディレクトリで公開する方法。&lt;/p>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>原因は通常通りにビルドすると &lt;code>/static/&lt;/code> でファイルを読み込んでしまうため、ルートディレクトリ上に配置する必要があります。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>React</category></item><item><title>【React + TypeScript】イベントから型を指定して渡す方法</title><link>https://c-a-p-engineer.github.io/react-typescript-onchange/</link><pubDate>Sat, 07 May 2022 15:30:00 +0900</pubDate><atom:modified>Sat, 07 May 2022 15:30:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-typescript-onchange/</guid><description>&lt;h1 id="react--typescriptイベントから型を指定して渡す方法">【React + TypeScript】イベントから型を指定して渡す方法&lt;/h1>
&lt;p>&lt;code>Material UI&lt;/code> を使用している際 &lt;code>onChange&lt;/code> イベント時にせっかく &lt;code>TypeScript&lt;/code> を使用しているのに &lt;code>unknown&lt;/code> の型指定しか出来なかったため、対策時のメモ&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category></item><item><title>【React + TypeScript】useState を利用してリアルタイムに入力値を反映させる</title><link>https://c-a-p-engineer.github.io/react-typescript-usestate/</link><pubDate>Mon, 02 May 2022 12:00:00 +0900</pubDate><atom:modified>Mon, 02 May 2022 12:00:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-typescript-usestate/</guid><description>&lt;h1 id="react--typescriptusestate-を利用してリアルタイムに入力値を反映させる">【React + TypeScript】useState を利用してリアルタイムに入力値を反映させる&lt;/h1>
&lt;p>&lt;code>useState&lt;/code> を利用してリアルタイムに入力値を反映させるメモ&lt;/p>
&lt;h2 id="usestate-を使用する">useState を使用する&lt;/h2>
&lt;p>React の &lt;code>useState&lt;/code> を使用する。&lt;br />
&lt;a href="https://ja.reactjs.org/docs/hooks-state.html" target="_blank" rel="nofollow noopener">ステートフックの利用法 - React&lt;/a>&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category></item><item><title>【React + TypeScript】axiosを使ってAPIに接続する</title><link>https://c-a-p-engineer.github.io/react-typescript-axios/</link><pubDate>Thu, 21 Apr 2022 01:00:00 +0900</pubDate><atom:modified>Thu, 21 Apr 2022 01:00:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-typescript-axios/</guid><description>&lt;h1 id="react--typescriptaxios-を使って-api-に接続する">【React + TypeScript】axios を使って API に接続する&lt;/h1>
&lt;p>axiosを使ってAPIに接続するメモ。&lt;br />
&lt;a href="https://github.com/axios/axios" target="_blank" rel="nofollow noopener">axios&lt;/a>&lt;/p>
&lt;h2 id="axios-インストール">axios インストール&lt;/h2>
&lt;p>&lt;code>axios&lt;/code> をインストールします。&lt;/p>
&lt;pre tabindex="0">&lt;code>npm install axios
&lt;/code>&lt;/pre>&lt;h2 id="get">Get&lt;/h2>
&lt;p>サンプルは当ブログの記事を取得するようにしています。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category></item><item><title>【React】React.FC、React.VFCを使わない方が良い？</title><link>https://c-a-p-engineer.github.io/react-fc-vfc/</link><pubDate>Mon, 04 Apr 2022 05:30:00 +0900</pubDate><atom:modified>Mon, 04 Apr 2022 05:30:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-fc-vfc/</guid><description>&lt;h1 id="reactreactfcreactvfcを使わない方が良い">【React】React.FC、React.VFCを使わない方が良い？&lt;/h1>
&lt;p>&lt;code>React.FC(FunctionComponent)&lt;/code>、&lt;code>React.VFC(VoidFunctionComponent)&lt;/code> 色々調べてみたらどちらも使わないほうが良いのではないかと考えになりました。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category></item><item><title>【React + Webpack】You may need an appropriate loader to handle this file type 解決方法</title><link>https://c-a-p-engineer.github.io/react-loader-handle-file-type/</link><pubDate>Thu, 31 Mar 2022 03:30:00 +0900</pubDate><atom:modified>Thu, 31 Mar 2022 03:30:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-loader-handle-file-type/</guid><description>&lt;h1 id="react--webpackyou-may-need-an-appropriate-loader-to-handle-this-file-type-解決方法">【React + Webpack】You may need an appropriate loader to handle this file type 解決方法&lt;/h1>
&lt;p>React + Webpack の環境で You may need an appropriate loader to handle this file type の解決方法メモ。&lt;/p>
&lt;h2 id="エラー">エラー&lt;/h2>
&lt;p>ビルドすると以下のエラーが発生。&lt;/p>
&lt;pre tabindex="0">&lt;code>ERROR in ./src/index.css 1:5
Module parse failed: Unexpected token (1:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
&amp;gt; body {
| margin: 0;
| font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, &amp;#39;Roboto&amp;#39;, &amp;#39;Oxygen&amp;#39;,
@ ./src/index.tsx 15:0-21
webpack 5.70.0 compiled with 1 error in 7589 ms
&lt;/code>&lt;/pre>&lt;h2 id="原因">原因&lt;/h2>
&lt;p>Webpack がCSSを読み込めなくてエラーが発生。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>React</category></item><item><title>create-react-app で hotreload させる</title><link>https://c-a-p-engineer.github.io/create-react-app-hotreload/</link><pubDate>Mon, 28 Mar 2022 01:30:00 +0900</pubDate><atom:modified>Mon, 28 Mar 2022 01:30:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/create-react-app-hotreload/</guid><description>&lt;h1 id="create-react-app-で-hotreload-させる">create-react-app で hotreload させる&lt;/h1>
&lt;p>docker環境で &lt;code>create-react-app&lt;/code> で作った環境上で hotreload が効かなかったのでその対処方法。&lt;br />
&lt;code>create-react-app&lt;/code> のバージョンは &lt;code>5.0.0&lt;/code> です。&lt;/p>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>原因はホットリロードに必要なソースの変更の監視と適用が出来なかったためです。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>React</category></item><item><title>【React + TypeScript】 react-router-dom を使ってルーティングを実装する</title><link>https://c-a-p-engineer.github.io/react-router-dom-typescript/</link><pubDate>Mon, 14 Mar 2022 02:00:00 +0900</pubDate><atom:modified>Mon, 14 Mar 2022 02:00:00 +0900</atom:modified><guid>https://c-a-p-engineer.github.io/react-router-dom-typescript/</guid><description>&lt;h1 id="git-複数のコミットを-rebase-を使って1つにまとめる">【Git】 複数のコミットを rebase を使って1つにまとめる&lt;/h1>
&lt;p>【React + TypeScript】 &lt;code>react-router-dom&lt;/code> を使ってルーティングを実装する&lt;/p>
&lt;h2 id="前提">前提&lt;/h2>
&lt;ul>
&lt;li>node 14.17.5&lt;/li>
&lt;li>react-router-dom 6.2.2&lt;/li>
&lt;/ul>
&lt;p>公式のチュートリアルを参考に進めます。&lt;br />
（公式のチュートリアルは &lt;code>React&lt;/code> のため少々記載とは異なります。&lt;/p></description><dc:creator>こぴぺたん</dc:creator><media:content url="https://c-a-p-engineer.github.io/images/thumbnail/React_Logo.svg" medium="image"><media:title type="html">featured image</media:title></media:content><category>React</category><category>TypeScript</category><category>React</category><category>TypeScript</category></item></channel></rss>