<?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 Rhabikhalifa on Medium]]></title>
        <description><![CDATA[Stories by Rhabikhalifa on Medium]]></description>
        <link>https://medium.com/@rhabikhalifa?source=rss-5dc0295c164b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Gl9UNXaI58sT1vyKVLWFEw.jpeg</url>
            <title>Stories by Rhabikhalifa on Medium</title>
            <link>https://medium.com/@rhabikhalifa?source=rss-5dc0295c164b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:35:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rhabikhalifa/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[Redux from with LazyFields]]></title>
            <link>https://medium.com/ocp-digital-factory/redux-from-with-lazyfields-99452e06c5ce?source=rss-5dc0295c164b------2</link>
            <guid isPermaLink="false">https://medium.com/p/99452e06c5ce</guid>
            <category><![CDATA[redux-form]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Rhabikhalifa]]></dc:creator>
            <pubDate>Thu, 07 May 2020 08:41:11 GMT</pubDate>
            <atom:updated>2020-05-07T10:33:32.497Z</atom:updated>
            <content:encoded><![CDATA[<h3>Redux-form with LazyFields</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*Eou9q2t9p3LUvR-sMRjnwQ.png" /></figure><p>Redux-form is a powerfull library that you need to use if you want to connect your form state with your redux store. it gives you amazing options such us: managing form state easily, async validation, field level validation.</p><p>I used it in many project, it works perfectly fine. but in my last project (under some functional needs) we wanted to render forms with an important number of fields, and here we noticed that the rendering of our app pages become slow.</p><p>In this article I will try to explain the solution that we used to deal with this problem.</p><p>Let’s start by briefly explaining redux-form :</p><p>So as I said previously, redux-from connect the form state with the redux store. the most imporant pieces of redux form are:</p><p><strong><em>formReducer </em>:</strong> function that tells how to update the Redux store based on changes coming from the application; those changes are described by Redux actions.</p><p><strong><em>reduxForm</em>() :</strong> function that takes configuration object and returns a new function; use it to wrap your form component and bind user interaction to dispatch of Redux actions.</p><p><strong>&lt;<em>Field</em>/&gt; :</strong> component that lives inside your wrapped form component; use it to connect the input components to the redux-form logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*l5B5ZaINBUz-7qWuYeqQHQ.png" /><figcaption>Source <a href="https://redux-form.com/8.3.0/docs/gettingstarted.md/">https://redux-form.com</a></figcaption></figure><p>If you want to know more about redux-form take a look on the <a href="https://redux-form.com/">documentation</a></p><p>For each &lt;Field/&gt; in your form redux will render the input given in the component property and register the field in the store by dispatching REGISTER_FIELD action.</p><p>It’s fine for small forms but when the forms are big redux form will dispatch a lot of REGISTER_FIELD actions, then you may have some performance issues to render the form for the first time.</p><p><em>The question here is: </em><strong><em>should we register all the form fields at the same time ?</em></strong></p><p>The answer that we give in our project to this question is <strong>‘No !!’</strong>. We decided to register a field only when needed, using a « LazyField » component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*oFOSIR3B5F-jy-CuV_2flw.png" /></figure><p><strong>&lt;LazyField/&gt;</strong> will show an input with the form ‘<strong>value’ </strong>got from the store. Once the user click on the input to edit the value, the <strong>&lt;Field/&gt;</strong> will be rendered and registered in the store.</p><p>Doing that redux form will register only needed fields in the store.</p><p><strong>Demo</strong>:</p><p>To showcase the difference, I rendered the same number of inputs using both implementations.</p><p><em>Case 1 : using &lt;Field/&gt;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OlH8WaIpnVlKnYGH0Sm_rA.png" /></figure><p><em>Case 2 : using &lt;LazyField/&gt;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqOk6f2c5ciImXLKiolJUg.png" /></figure><p>As expected, using the &lt;<strong>LazyField/&gt; </strong>componenet takes almost half time, which is very significant when dealing with large forms.</p><p><strong>Conclusion</strong></p><p>In some situations you may need to render a big form with an improtant number of fields, one of the chalenges that you will face is the “rendring performance challenge”.</p><p>The idea that I want to share in this article is: <strong>You don’t need to register all the fields of your redux form (<em>with a big number of fields</em>) in the store from the first rendering.</strong></p><p>One of the solution that you can use is <strong>‘Lazy Field’</strong>.</p><p>Hope that the article helps you, and thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99452e06c5ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocp-digital-factory/redux-from-with-lazyfields-99452e06c5ce">Redux from with LazyFields</a> was originally published in <a href="https://medium.com/ocp-digital-factory">OCP digital factory</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>