<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>js - 標籤 - weichen's note</title><link>https://droyuki.github.io/tags/js/</link><description>js - 標籤 - weichen's note</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><managingEditor>droyuki@gmail.com (weichen)</managingEditor><webMaster>droyuki@gmail.com (weichen)</webMaster><lastBuildDate>Wed, 06 May 2020 14:36:54 +0800</lastBuildDate><atom:link href="https://droyuki.github.io/tags/js/" rel="self" type="application/rss+xml"/><item><title>React 單元測試 - Test Was Not Wrap in Act ?</title><link>https://droyuki.github.io/2020/05/react-test-was-not-wrap-in-act/</link><pubDate>Wed, 06 May 2020 14:36:54 +0800</pubDate><author>weichen</author><guid>https://droyuki.github.io/2020/05/react-test-was-not-wrap-in-act/</guid><description>Warning: An update to Demo inside a test was not wrapped in act(&amp;hellip;). 最近在寫單元測試，遇到這個神奇的 warning，記錄一下。 情境: 假設有一個元件，點了會更新 state 並呼叫 props.onChange class 版: 1 2 3 4</description></item><item><title>透過 redux-thunk 處理非同步 action</title><link>https://droyuki.github.io/2020/01/redux-thunk-async-action/</link><pubDate>Fri, 17 Jan 2020 16:06:01 +0800</pubDate><author>weichen</author><guid>https://droyuki.github.io/2020/01/redux-thunk-async-action/</guid><description>首先必須知道幾個重點 Redux 不會管你是否同步，想要更新 store ，就必須呼叫 dispatch() Redux 原始碼中，dispatch function 的實作是此 function 會回傳其第一個參數 1 2 // 也就是若執</description></item><item><title>JS 繼承(2): constructor 的執行順序</title><link>https://droyuki.github.io/2019/09/js-extends-constructor/</link><pubDate>Wed, 04 Sep 2019 16:57:11 +0800</pubDate><author>weichen</author><guid>https://droyuki.github.io/2019/09/js-extends-constructor/</guid><description>三個 class A, B, C，依序繼承，測試 constructor 的執行關係 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 class A { constructor() { console.log(&amp;#39;A has been instantiated&amp;#39;, this) } static color =</description></item><item><title>JS 繼承(1): class property跑去哪了？</title><link>https://droyuki.github.io/2019/09/js-extends-class-property/</link><pubDate>Tue, 03 Sep 2019 16:57:11 +0800</pubDate><author>weichen</author><guid>https://droyuki.github.io/2019/09/js-extends-class-property/</guid><description><![CDATA[探討 JS 繼承的 class property 行為 Class A extends Component 1 2 3 4 5 6 7 8 9 10 11 12 class A extends Component { static color = &#34;red&#34;; counter = 0; arrowOnClick = () =&gt; { console.log(&#34;A arrowOnClick&#34;); } onClick(){ console.log(&#34;A onClick&#34;); } } 經由 Babel 轉譯後，class properties 都會被移到 constructor]]></description></item><item><title>React.js 到底要在哪 bind this ?</title><link>https://droyuki.github.io/2019/05/react-bind-this/</link><pubDate>Fri, 24 May 2019 13:05:27 +0800</pubDate><author>weichen</author><guid>https://droyuki.github.io/2019/05/react-bind-this/</guid><description>TL;DR class property + arrow function 才是王道 情境: 假設你有一個&amp;lt;Button /&amp;gt;元件，其 onClick 中會需要時使用 this.props 或 this.state 這時就會需要將 onClick function 綁定元件的 this。 而綁</description></item></channel></rss>