<?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[React Blog - Medium]]></title>
        <description><![CDATA[This blog provides clear understanding about hard concepts of React. - Medium]]></description>
        <link>https://medium.com/react-blog?source=rss----4a09cf0a80f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>React Blog - Medium</title>
            <link>https://medium.com/react-blog?source=rss----4a09cf0a80f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:43:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/react-blog" 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 in Simple Terms]]></title>
            <link>https://medium.com/react-blog/redux-in-simple-terms-79fa9c8c871f?source=rss----4a09cf0a80f---4</link>
            <guid isPermaLink="false">https://medium.com/p/79fa9c8c871f</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Daham Positha Pathiraja]]></dc:creator>
            <pubDate>Tue, 14 Apr 2020 19:08:27 GMT</pubDate>
            <atom:updated>2020-04-14T19:08:27.203Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From this article, I would like to explain to you how to use Redux to solve the same problem which has been solved by pure React differently. Even though this example may not show the actual usage of Redux, you will be capable of getting a proper idea on how to set up Redux for a React frontend.</em></p><p>Suppose you have two React elements. I will name the outer element as OuterElement and the inner element as InnerElement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*Ylz9A-69wfcVBPxgmHvg0A.png" /><figcaption>Figure 1: Updating state of a outer React component through a callback from a inner React component</figcaption></figure><p>To mimic the above scenario I have implemented the following code snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b23782780dc813f73da52df50cb42a1/href">https://medium.com/media/4b23782780dc813f73da52df50cb42a1/href</a></iframe><p>To represent the outer component’s state I will use an input field called Outer Text. The state value called outerText will be the value for above input field. The function in the OuterElement called onInnerTextChanged is passed as a prop to the InnerElement so that whenever its input field changed that can be notified to OuterElement via that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*w-oVAgdLJZScbmaukav-Jw.png" /><figcaption>Figure 2: Behavior of inner and outer text fields</figcaption></figure><h3><strong>Lets solve the same problem with Redux</strong></h3><p>Suppose we use a common store to keep changes happen in all React views and any of them can be observers to that store at any time when they need it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*rS9LJ9D5fh4fexViJSLeTw.png" /><figcaption>Figure 3: OuterElement getting the state of InnerElement through a common store.</figcaption></figure><p>This is something very similar to what happens in Redux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*mqEH72SvzvbAQXPcAzQaYA.png" /><figcaption>Figure 4: How React view can be connected to Redux</figcaption></figure><p>As shown in Figure 4, whenever a change which others are interested on happens in the InnerElement it submits that event to Redux store in <strong>form of an Action. </strong>Action is nothing but a normal object with a type field as a mandate and also other attributes if needed. The action can be dispatched to the store using the dispatcher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*g7ngCqVWxIccFOYhEumkZw.png" /><figcaption>Figure 5: Example action</figcaption></figure><p>The State within the store can’t be directly updated (here I will not explain what is the reason for that). The State can only be updated through a layer called Reducer which takes<strong> the current state and the incoming action as arguments.</strong></p><p>Through out the rest of the article I will show you how the setup in Figure 4 can be implemented step by step.</p><p><strong>Create the Reducer and the Store</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*Uwm-uEDTcSoSEP-mFha_uA.png" /><figcaption>Figure 6: Create the Reducer and Store</figcaption></figure><p>Following code snippet will do the above for you.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66ce0efd44b3633c2b6dba4852262a9d/href">https://medium.com/media/66ce0efd44b3633c2b6dba4852262a9d/href</a></iframe><p><strong>Provide Redux to React Views</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*4xzLIfvn01QccGTohLXpig.png" /><figcaption>Figure 7: Provide Redux to React views</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e298ce24ec1b134587067f318d43b44/href">https://medium.com/media/3e298ce24ec1b134587067f318d43b44/href</a></iframe><p><strong>Connect React Views with the Store</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1246af9e3f5b8bb31232f3955a311edb/href">https://medium.com/media/1246af9e3f5b8bb31232f3955a311edb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79fa9c8c871f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-blog/redux-in-simple-terms-79fa9c8c871f">Redux in Simple Terms</a> was originally published in <a href="https://medium.com/react-blog">React Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Situation where Process is better than a Library]]></title>
            <link>https://medium.com/react-blog/a-situation-where-process-is-better-than-a-library-3f113a87e600?source=rss----4a09cf0a80f---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f113a87e600</guid>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[process]]></category>
            <category><![CDATA[application-development]]></category>
            <dc:creator><![CDATA[Daham Positha Pathiraja]]></dc:creator>
            <pubDate>Mon, 26 Nov 2018 02:10:11 GMT</pubDate>
            <atom:updated>2018-11-27T06:59:17.880Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently had an argument with one of my colleagues about expanding the capabilities of a crucial application(consists of highly important functionality) by introducing a 3rd party library as a dependency for that application.</p><p>Following are the two basic ways of giving that capability to the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*8rwv51qM1trKdK4Zkr-8sg.png" /><figcaption>Figure 1: Capability as a library vs capability as another process</figcaption></figure><ul><li><strong>Adding capability as a 3rd party library - </strong>In this method, the new capability is added as an internal compilation dependency for your program.</li><li><strong>Using capability as another process - </strong>In this methods, the new capability will not be an internal compilation dependency. It gets compiled separately and will be run as another process. New capability can be used as a service exposed by that particular process.</li></ul><p>I would have agreed with my colleague’s suggestion if we are going to add this capability as the main function of the application or as an extension to the main functionality. However, our context is as follows.</p><ul><li>The mainly expected functionality of the application should be well tested minimal component.</li><li>Capabilities which are newly added change frequently. Hence frequent deployments are needed.</li><li>Environments cannot be assumed as homogeneous.</li></ul><p>One of the arguments of my colleague is, <strong>introducing another process will be an overhead to the system as we need to allocate resources to it even though we don’t use that process frequently.</strong></p><p>However, when using a library, it will be an internal compilation dependency for our program which adds another complexity by introducing newer code lines.</p><h3>Errors which damage the <strong>Process</strong> Address Space</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EoLEGazM6ma7rFHY6qRahQ.png" /><figcaption>Figure 2: Address space is getting crashed by a 3rd party library and a process</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*RhCvFeHS5i6FG3v7UsqZQw.png" /><figcaption>Figure 3: Runtime is getting crashed by a 3rd party library and a process</figcaption></figure><p>One may think that 3rd party library cannot crash the application as long as we properly handle the places where that library is being used. However, if the 3rd party library does something which damages the <strong>Process</strong> <strong>Address Space</strong>, nothing can be done to prevent it. Memory Overflows, Stack Overflows, and various kill commands are such situations.</p><blockquote><strong>Thread Crash vs Process Crash</strong></blockquote><blockquote>A crashing process won’t bring down other processes, whereas a crashing thread will probably wreak havoc with other threads.<br>Not all thread exceptions can be captured with try-catch. Threads can do much more than raising an exception. A rogue thread can, via buggy native or ctypes code, trash memory structures anywhere in the process, including the python runtime itself, thus corrupting the entire process.</blockquote><h3>The problem of having unmet dependencies</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*wQBt27Ia9Wnx_Y9-G7Q0jA.png" /><figcaption>Figure 4: met dependencies vs unmet dependencies</figcaption></figure><p>When we introduce 3rd party library we need to make sure all dependencies which are expected by that library as prerequisites should be satisfied. This is not a huge problem if we can confirm the homogeneity of target environments. If environments are heterogeneous the compilation of the codebase will be a failure.</p><h3>Lack of autonomy for the application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*0P5FaSR75Y6z5SBPIv4gSA.png" /><figcaption>Figure 5: Migrating an application from Language A to Language B</figcaption></figure><p>Whenever you need to do major transformations(i.e switch the entire language or the version which it is written in) to the application, you need to make sure the 3rd party library is also migrated properly.</p><h3>Cannot change(i.e introduce new version) unless you recompile/redeploy your program</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQl5-7dlwhUO11EwrwrXkQ.png" /><figcaption>Figure 6: Introducing a new version</figcaption></figure><p>Every time when you introduce new versions of the 3rd party library you need to deploy the whole program again to take that new version. This is not a good condition for an application whose fundamental functionality is another thing. Recompiling the program for another purpose other than for amending above fundamental functionality can be an additional risk for the application.</p><h3>Special Situations like Global Interpreter Lock in Python</h3><p>In Python, because of GIL (Global Interpreter Lock), a single python process cannot run threads in parallel (utilize multiple cores). It can, however, run them concurrently (context switch during I/O bound operations)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f113a87e600" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-blog/a-situation-where-process-is-better-than-a-library-3f113a87e600">A Situation where Process is better than a Library</a> was originally published in <a href="https://medium.com/react-blog">React Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>