<?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: Egor Stronhin</title>
    <description>The latest articles on DEV Community by Egor Stronhin (@egorxyz).</description>
    <link>https://dev.to/egorxyz</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%2F679546%2Fea86a418-6abe-4951-857f-9e65e8650cd3.png</url>
      <title>DEV Community: Egor Stronhin</title>
      <link>https://dev.to/egorxyz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/egorxyz"/>
    <language>en</language>
    <item>
      <title>Custom react hooks with JSX</title>
      <dc:creator>Egor Stronhin</dc:creator>
      <pubDate>Tue, 26 Jul 2022 06:19:29 +0000</pubDate>
      <link>https://dev.to/egorxyz/custom-react-hooks-with-jsx-4jdj</link>
      <guid>https://dev.to/egorxyz/custom-react-hooks-with-jsx-4jdj</guid>
      <description>&lt;p&gt;Over time our react components become bigger and bigger. The easiest way to fix it is to create more small components. But what to do with components which require some methods or states?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take, for example, the modal component. To open and close this component, we need to write the following code during each use&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s wrap now all logic related to toggle modal state to a custom hook&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You can continue to use modal props like text and change them during application runtime&lt;/p&gt;

&lt;p&gt;Let’s refactor components with the new custom hook&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Your code now looks much cleaner!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/react-custom-hook-with-jsx-qkiftv"&gt;Codesandbox playground&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>hooks</category>
    </item>
  </channel>
</rss>
