<?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 Steven Su on Medium]]></title>
        <description><![CDATA[Stories by Steven Su on Medium]]></description>
        <link>https://medium.com/@xpsteven?source=rss-8e4e3ea9a583------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*7vAZ_7YxKW4tBUB6yO_RaQ.jpeg</url>
            <title>Stories by Steven Su on Medium</title>
            <link>https://medium.com/@xpsteven?source=rss-8e4e3ea9a583------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 03:06:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xpsteven/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[React Function Component Pattern 2：用 useRef / useEffect / useCallback 封裝 callback 函數]]></title>
            <link>https://medium.com/reactfunctioncomponentnote/react-function-component-pattern-2-%E7%94%A8-useref-useeffect-usecallback-%E5%B0%81%E8%A3%9D-callback-%E5%87%BD%E6%95%B8-fc4920f15d7d?source=rss-8e4e3ea9a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc4920f15d7d</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Steven Su]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 01:17:26 GMT</pubDate>
            <atom:updated>2019-04-19T02:02:45.199Z</atom:updated>
            <content:encoded><![CDATA[<p>Pure Component 是 React 中常見提升效能的方式，如果傳遞 props 給 Pure Component 時有用到 propA={{…props.A}} 或 onChange={(e) =&gt; {...}}，那有用 Pure Component 跟沒用一樣，因為每次 render 都還是會產生新的物件或函數，所以 shouldComponentUpdate 會回傳 true。</p><p>但使用 arrow function 又是人之常情，我們能做的就是避免效能大幅度惡化。可以透過合使用 useRef 和 useEffect 和 useCallback 來避免 arrow function 往下擴散，造成大量 render。</p><p>此樣式適合用在大型的共用元件，大型元件裡面有小元件，父元件要傳遞 callback 下去給子元件或者父元件會 wrap callback 才傳給子元件。例如：萬用表單中的 onChange onXXX、萬用表格中的行內編輯。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37b26cbe232b5f54d48ad64e7ac2d592/href">https://medium.com/media/37b26cbe232b5f54d48ad64e7ac2d592/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc4920f15d7d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactfunctioncomponentnote/react-function-component-pattern-2-%E7%94%A8-useref-useeffect-usecallback-%E5%B0%81%E8%A3%9D-callback-%E5%87%BD%E6%95%B8-fc4920f15d7d">React Function Component Pattern 2：用 useRef / useEffect / useCallback 封裝 callback 函數</a> was originally published in <a href="https://medium.com/reactfunctioncomponentnote">萬達寵物系統發展部</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Function Component Pattern 1：用 Factory 封裝靜態變數]]></title>
            <link>https://medium.com/reactfunctioncomponentnote/react-function-component-pattern-1-%E7%94%A8-factory-%E5%B0%81%E8%A3%9D%E9%9D%9C%E6%85%8B%E8%AE%8A%E6%95%B8-62744e44deda?source=rss-8e4e3ea9a583------2</link>
            <guid isPermaLink="false">https://medium.com/p/62744e44deda</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Steven Su]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 00:31:45 GMT</pubDate>
            <atom:updated>2019-04-18T05:41:26.251Z</atom:updated>
            <content:encoded><![CDATA[<p>會重複使用的元件，其中有些 props 在開發時期就能決定，且在執行時期也都不會變更。舉例：開發一個共用的 Form 元件給後台使用，Form 的標題會是固定的，或者要把 Form 的資料存到 localStorage 時用的 key 值也是固定且開發時期能決定。</p><h4>規則與應用</h4><ol><li>靜態 props 用 <strong>s</strong> 開頭</li><li>在 Factory 檢查靜態 props 的時候，有錯應擲出錯誤。</li></ol><h4>範例</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03cc499bfd9eae8659d17c00adf3a2e6/href">https://medium.com/media/03cc499bfd9eae8659d17c00adf3a2e6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62744e44deda" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactfunctioncomponentnote/react-function-component-pattern-1-%E7%94%A8-factory-%E5%B0%81%E8%A3%9D%E9%9D%9C%E6%85%8B%E8%AE%8A%E6%95%B8-62744e44deda">React Function Component Pattern 1：用 Factory 封裝靜態變數</a> was originally published in <a href="https://medium.com/reactfunctioncomponentnote">萬達寵物系統發展部</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>