<?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 Veera on Medium]]></title>
        <description><![CDATA[Stories by Veera on Medium]]></description>
        <link>https://medium.com/@vraa?source=rss-cf0185597353------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M-IKpNuw4TV4GtzrheI5BQ.jpeg</url>
            <title>Stories by Veera on Medium</title>
            <link>https://medium.com/@vraa?source=rss-cf0185597353------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:34:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vraa/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[Start create-react-app in a specific browser]]></title>
            <link>https://medium.com/@vraa/start-create-react-app-in-a-specific-browser-c13a406deb3e?source=rss-cf0185597353------2</link>
            <guid isPermaLink="false">https://medium.com/p/c13a406deb3e</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Veera]]></dc:creator>
            <pubDate>Sat, 11 Jan 2020 15:56:35 GMT</pubDate>
            <atom:updated>2020-01-11T15:56:35.736Z</atom:updated>
            <content:encoded><![CDATA[<p>Here’s a quick tip, if you haven’t known already:</p><p>You can specify which browser to start your create-react-app. By default, it uses the system browser. But it can be overridden with BROWSER environment variable.</p><ol><li>Create a .env file in your root directory (if not already there)</li><li>Add BROWSER=chrome line to that file. (or BROWSER=firefox or BROWSER=none to disable opening browser)</li><li>Now start the create-react-app.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c13a406deb3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inline edit using Higher Order Components in React]]></title>
            <link>https://medium.com/@vraa/inline-edit-using-higher-order-components-in-react-7828687c120c?source=rss-cf0185597353------2</link>
            <guid isPermaLink="false">https://medium.com/p/7828687c120c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[editing]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Veera]]></dc:creator>
            <pubDate>Sat, 27 Jan 2018 23:27:34 GMT</pubDate>
            <atom:updated>2018-11-09T20:52:44.248Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wyxuq21keffc5b0d_lMkUw.jpeg" /></figure><p>Higher Order Components (HOC) are simple yet powerful technique in React that helps us to reuse logic across components. Simply put, a HOC is a <em>function </em>that takes in a React component, wrap it in a new component with additional logic and returns the wrapped component. Sounds fun, huh!?</p><p>Let’s understand Higher Order Components with the help of some practical example. Let’s say you need to create inline edit capability for texts in your app. You may be using any tag to style the text -h1, p, ul, strong , but you want the user to edit it just by clicking on it. You also want to retain the styles of the text while editing it as well. For example, the below image is just an H1 and there’s no textbox involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*xDHdXqj8QS9CflDA3lYfqw.gif" /><figcaption>Editable Components in React</figcaption></figure><pre>let EditableDiv = contentEditable(&#39;div&#39;);<br>let EditableHeading = contentEditable(&#39;h1&#39;);</pre><pre>&lt;EditableDiv value=&#39;Initial text&#39;/&gt;<br>&lt;EditableHeading value=&#39;Editable Heading&#39; /&gt;</pre><p>You get the idea, right!? Let’s see how we can do this with the help of HOC.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d537e22b698f7d437355aa6a024fed2/href">https://medium.com/media/0d537e22b698f7d437355aa6a024fed2/href</a></iframe><p>As you can see, the contentEditable function takes in a React component and returns a new React component, wrapping the original component. In the new component, you can add any extra logic you want. In our case, we want to add the ability to edit he text inline and here’s how it’s done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9526864a51bcd9065366615c65c5c0e1/href">https://medium.com/media/9526864a51bcd9065366615c65c5c0e1/href</a></iframe><p>With the above implementation, you could just pass in any component to it and instantly make it inline editable, like this:</p><pre>let EditableP = contentEditable(&#39;p&#39;);<br>&lt;EditableP vallue=&quot;this&quot; /&gt;</pre><p>Here’s the working solution: <a href="https://codesandbox.io/s/j4qr62m0w5">https://codesandbox.io/s/j4qr62m0w5</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7828687c120c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why using an index as Key in React is probably a bad idea?]]></title>
            <link>https://medium.com/@vraa/why-using-an-index-as-key-in-react-is-probably-a-bad-idea-7543de68b17c?source=rss-cf0185597353------2</link>
            <guid isPermaLink="false">https://medium.com/p/7543de68b17c</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Veera]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 06:15:07 GMT</pubDate>
            <atom:updated>2018-01-24T06:18:03.134Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuoKHkwDfCAWH0ElI_LtAw.png" /></figure><p>Let’s say you have a list of items and you want to show them as ul, li elements in your React app. When the user clicks on one of the list item, you want to remove that item and re-render the list.</p><p>In React, you would do something like this (for brevity, only the relevant code is shown. Full example is in here: <a href="https://codesandbox.io/s/pkqrj851nq">https://codesandbox.io/s/pkqrj851nq</a>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7975f34a07aa3371c09e3ba8536d68ff/href">https://medium.com/media/7975f34a07aa3371c09e3ba8536d68ff/href</a></iframe><p>Of course, in React, you are required to pass in a unique key value for all elements of an array. Else, you will see this warning in console.</p><pre>Warning: Each child in an array or iterator should have a unique “key” prop.</pre><p>So, as a lazy developer, you would simply pass in the loop’s index value as the key value of the child element.</p><pre>{this.state.fruits.map( (fruit, <strong>index</strong>) =&gt; &lt;li key={<strong>index</strong>} ... /&gt; )}</pre><p>With the above code, you will see the list rendered as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*fue_ygGkjtjjKPefOeS7dw.gif" /><figcaption>With index as Key, removing any item will always apply the transition to the last item</figcaption></figure><p>Notice how the leave transition is always applied to the last item in the list, even though correct item was removed? This isn’t what we want, is it?</p><p>The reason is because you are not passing an <em>unique </em>key for each child element in the list. Without a unique key, React couldn’t differentiate if the element was removed or just the content is changed.</p><p>So, when you remove the first item in the list, React’s diff algorithm <em>thinks </em>only the content got changed, because the key is not changed. So, it just updates the content and not physically removing the first element from DOM, hence the leave animation is not getting applied. But when it comes to the last element, as one item was already removed from list, React <em>thinks </em>the last item was removed and it physically removes the last item from DOM, thus applying the leave animation.</p><p>To fix, we just need to make sure to pass in a unique key value for each child elements. For our case, we could just pass in the item name, instead of it’s index.</p><pre>{this.state.fruits.map( (fruit, <strong>index</strong>) =&gt; &lt;li key={<strong>fruit</strong>} ... /&gt; )}</pre><p>Notice the change in key value. With this fix, we will end up with this result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*dgz2XZh-Y7zZymECvz-HTA.gif" /><figcaption>With unique key, removing an item will correctly apply ‘leave’ transition to it.</figcaption></figure><p>You can find the source code for this example in here: <a href="https://codesandbox.io/s/pkqrj851nq">https://codesandbox.io/s/pkqrj851nq</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7543de68b17c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>