<?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 Nick Cherny on Medium]]></title>
        <description><![CDATA[Stories by Nick Cherny on Medium]]></description>
        <link>https://medium.com/@cherny.web?source=rss-370256c1efa1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*UtfqNws_YlGM8n7l.</url>
            <title>Stories by Nick Cherny on Medium</title>
            <link>https://medium.com/@cherny.web?source=rss-370256c1efa1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 14:45:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cherny.web/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[The React Hooks & Compose]]></title>
            <link>https://medium.com/@cherny.web/the-react-hooks-compose-2b8fc7275948?source=rss-370256c1efa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b8fc7275948</guid>
            <category><![CDATA[recompose]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hooks]]></category>
            <dc:creator><![CDATA[Nick Cherny]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 10:06:17 GMT</pubDate>
            <atom:updated>2019-03-18T10:20:17.617Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! I’m Frontend Developer) It’s my first pos, and I hope you will help me do other post beater, but sorry if post not interesting or stupid.</p><p>I’dl talk about React, Recompose, and like you can write beater UI Components without pain.</p><p>What we know about Components in React? We are able to make:</p><ul><li>Statefull Components</li><li>Stateless Component (usually functional style components)</li><li>Pure Component</li></ul><p>Okey, for us are interesting Statefull and Stateless, what that men. Statefull component with state, Stateless without. looking example</p><p>Statefull Component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bu7gv2ynMRLFWb6Iwjc7g.png" /></figure><p>Stateless Component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*JINJlsyCrG2IjGFC5uvAkQ.png" /></figure><p>ease) But if we wont reuse some state in other UI. Can we do this? YES, and we have <strong>HOC, </strong>it’s pattern from Function Programing word, it’s when we get some Component1 and wrap other Component but give some functionality to Component1. does it sound difficult? Don’t wary it’s easier than it sounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9P8xpP8Hgj8a0sAPtKJv-Q.png" /></figure><p>But if we have a lot of <strong>HOC</strong>’s, we need some utils which is help us to combine <strong>HOC</strong>’s. writing are combine function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ToyGC3_WSMZUzbMxVbWAsw.png" /></figure><p>looks beautiful! But what it do, combine except some functions, and then call they with ownerComponent. Okey, lets talk about why it’s so cool.</p><ul><li>Separate logic between presentations</li><li>Reusable logic</li><li>Testable logic</li></ul><p>There are library <strong>Recompose</strong>, it’s like Lodash for React, but maintainer move to Facebook and with team create <strong>hooks</strong>. Great! But want to told you not only about <strong>hooks/hoc</strong>, this post about how you can struct your Components. What is UI Component? It’s some View (HTML+CSS/JSX+CSS, SCSS, JSS) and some logic (create some handlers, serialize data and call some callbacks), I gees beater if we separate this two things. Why is it beater? because we can change our View without affecting logic, and we can reuse logic, and easier write tests. We can make snapshots tests for View, and integration for logic.</p><p>looking for some ease example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enE8cBK-E6vkQPko_KNtvQ.png" /></figure><p>What we do. we create card with User info, when we hide details information and show only if user click for button, it’s educational example. I liked use HOC’s syntax when you wrap Component with function, and I rewrite last code for that sugar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0-jo9I8WvYSy1ORMXyB8w.png" /></figure><p>I guess it look so perfectly)</p><p>Code you can fined in Github</p><ul><li><a href="https://github.com/NickCherny/example-enhance-hooks/tree/master/src/UserCard">https://github.com/NickCherny/example-enhance-hooks/tree/master/src/UserCard</a></li></ul><p>If you have some questions, please tall me about there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b8fc7275948" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>