<?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 Alankar Anand on Medium]]></title>
        <description><![CDATA[Stories by Alankar Anand on Medium]]></description>
        <link>https://medium.com/@etherealm?source=rss-513e9f637f42------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xz63rGuCxmkmzS7AmteIig.jpeg</url>
            <title>Stories by Alankar Anand on Medium</title>
            <link>https://medium.com/@etherealm?source=rss-513e9f637f42------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:19:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@etherealm/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[It’s Time for Medium writers to move on… from Images]]></title>
            <link>https://medium.com/@etherealm/its-time-for-medium-writers-to-move-on-from-images-8bebcc86e772?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bebcc86e772</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[features]]></category>
            <category><![CDATA[viewpoints]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 07:58:36 GMT</pubDate>
            <atom:updated>2020-04-27T08:05:39.907Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first stumbled upon Medium, I was impressed by the minimalistic design of medium. I thought, and still do in bits and pieces, that all the focus was on providing the readers an optimal reading experience. But now, under lockdown due to the coronavirus situation, when I have limited bandwidth and unlimited time, I find the images used in the blog, mostly the featured image or whatever it is called, is quite useless. Actually in most cases it’s totally useless and doesn’t have any correlation with the content. So I feel Medium writers should refrain from adding images of any kind which do not add any value to the post apart from making it take longer to load. If someone is opening a post based on the image and not the title then they’re on the wrong website, I guess.</p><p>P.S. I will be removing all the images from my posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bebcc86e772" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting rid of relative paths in imports using webpack alias]]></title>
            <link>https://medium.com/@etherealm/getting-rid-of-relative-paths-in-imports-using-webpack-alias-78d4bf15bb42?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/78d4bf15bb42</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Thu, 16 May 2019 18:56:54 GMT</pubDate>
            <atom:updated>2019-05-18T21:57:17.104Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>No more “import config from ‘../../../utilities/configs’ ”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*L9ch46qlfqni0B7PYJkdpA.jpeg" /><figcaption>Kilimanjaro</figcaption></figure><p>React emphasises on modular code and component architecture. Dividing the app into presentational and container components makes the code more readable and also reusable. One thing that I have found helpful while using components is using webpack alias to import components.<br> <br> Traditionally we import a component by mentioning the directory using combination of dots and slashes. The problem with this approach is that this is very error prone. In case you move one file from one place to another, you may have to change ( manually, based on the IDE you are using) all the imports to point to the new location.</p><p>Webpack provides a way to solve this problem. You can use alias to point to the components and use that alias everywhere in the project.</p><p>How it works ?</p><p>You can add an alias under resolve option provided by web pack in the web pack config file.</p><pre>resolve: {<br>  alias: {<br>     Utilities: path.resolve(__dirname, ‘src/utilities/’),<br>     Templates: path.resolve(__dirname, ‘src/templates/’)<br>  }<br>}</pre><p>So when importing from these folders you can use absolute paths like ‘Utilites/&lt;component&gt;’ to fetch the component.</p><pre>// Instead of using relative paths<br>import config from ‘../../../utilities/configs&#39;</pre><pre>// Now you can do<br>import config from ‘Utilities/configs&#39;</pre><p>Also, in case you change the location of a file or folder, you only need to update the alias to point to the new location.</p><p>For more info: <a href="https://webpack.js.org/configuration/resolve/">https://webpack.js.org/configuration/resolve/</a></p><p>Checkout my other posts:</p><ol><li><a href="https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b">Why is customer acquisition a wrong metric to measure startup’s growth</a>.</li><li><a href="https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2">What’s the difference between super and super(props) in ES6</a>.</li><li><a href="https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5">CurrentTarget vs Target in Js</a>.</li><li><a href="https://medium.com/@etherealm/node-and-react-a-brief-introduction-99b672262fed">A brief introduction of Node, React and NPM</a>.</li><li><a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">Named export vs Default export in ES6.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78d4bf15bb42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why is customer acquisition a wrong metric for measuring Growth ?]]></title>
            <link>https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/b53d8ca8764b</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Tue, 29 May 2018 21:27:58 GMT</pubDate>
            <atom:updated>2020-04-27T07:51:35.838Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why is Customer acquisition a wrong metric for measuring Growth ?</h3><p>People have a threshold in terms of spending habits. Startups try and make the people accustomed to the new services/products by providing it at a discount or for free. Thereby setting a new threshold.</p><p>Threshold doesn’t always mean lower costs. Sometimes it’s better user experience, better output or simply better customer satisfaction.</p><h4><strong>When do Startups know a threshold has reached ?</strong></h4><p>Startups spend a lot of money in the form of discounts, freebies, advertisement for customer acquisition and product adoption. A number of metrics are used to keep track of growth.</p><p>Number of users is never a good metric to judge the success/failure of a product.</p><p>Customer Retention / Repeat customers is a much better metric because it tells you that users are liking the products and are readily coming back.</p><p>Getting a new customer could be for a varied number of reasons like good advertisement, niche market, less competition, word of mouth publicity, etc. but customer retention is only possible with either a good product or a niche market. These users don’t require continued spending on advertisement to be retained.</p><blockquote>Threshold → Repeat Customers</blockquote><p><strong>False positives for threshold</strong></p><ol><li>Continuous discounts / freebies.</li><li>Niche market</li></ol><p><strong>What to do when a threshold is reached ?</strong></p><p>When a product reaches a threshold, it’s a sign that the product is market fit. Consumers like the product enough to come back and continued investment in advertisement and new customer acquisition will only grow the user base, right ?</p><p>Not really.</p><p>When users start coming back on their own accord, the focus can shift to getting more users.</p><p>More users while adds to the metric and increase the cash flow in the short run but could be detrimental in the long.</p><p><strong>Why ?</strong></p><p>Because the ecosystem around the product was not updated to handle the added traffic. This, after a while could lead to bad user experience, which decreases the repeat customers if not handled properly. So, when the threshold is reached, the focus should also be on providing a better product experience.</p><p>Advertisement is not the only way to get new users. When users are satisfied it could lead to referrals. But if the ecosystem is not updated, not only the referred users will be lost but also the current ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCHj0hzN0talNkdt44uAnw.jpeg" /><figcaption>Not an ideal situation</figcaption></figure><p><strong>How to provide a better product experience ?</strong></p><blockquote>By taking feedback from the users and working on it.</blockquote><blockquote>By providing an experience, not just a product, to users.</blockquote><p>Thanks for reading. Checkout some of my other posts:</p><ol><li><a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">Named export vs Default export in ES6.</a></li><li><a href="https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2">super() vs super(props) in constructor of react.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53d8ca8764b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node and React — A brief introduction]]></title>
            <link>https://medium.com/@etherealm/node-and-react-a-brief-introduction-99b672262fed?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/99b672262fed</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Thu, 05 Apr 2018 21:34:04 GMT</pubDate>
            <atom:updated>2020-04-27T07:59:35.292Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Node and React — A brief introduction</strong></p><p><em>Disclaimer: This was originally written for a friend of mine who wanted to know how Node/Express and React fit together. I thought of putting it here as I feel it can be helpful to others starting the journey. This is not a guideline on how to use Node or React and shouldn’t be treated as such. It’s just to get you familiar with the ecosystem so there’s minimal code.</em></p><p>Node and React are the two hot topics since the last few years. In my opinion, this is the best time to learn React and Node.</p><p><a href="https://nodejs.org/en/">Node.js</a> is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.</p><p>Express is a framework based on NodeJS which is used to create server side for an app.</p><p>Before learning Node and React, remember the following:</p><ul><li>Node uses callback functions, a lot. React uses Promises as ES6 uses promises. So, get familiar with ES6<strong>.</strong></li><li>Node also uses requireJS format for importing modules. // var express = require(‘express’).</li><li>React uses ES6 which uses import format. // import express from ‘express’. Also read: <a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910</a></li><li>NPM is used for installing modules dependencies. // mentioned at the end of article</li></ul><p>Best way to learn node, or anything else, is to build something with it.</p><p>Try building a basic crud app like a blog or todo app using Node and express.</p><p>Then move to React.</p><p><strong>A little bit of history to get started.</strong></p><blockquote>So, not so long time ago i.e. initially we had server side rendered pages. Then came client side rendering using Single page applications.</blockquote><p>In client side technologies, there are 3 types:</p><ol><li>Libraries like jQuery which manipulate Dom.</li><li>MVC frameworks like angular, emberJS which introduce the concept of MVC in frontend and</li><li>View library / framework like React</li></ol><p><strong>How is angular different than react you ask ?</strong></p><p>Angular has two way binding which means that there are two ways to update data in angular. Either through view or through the model which is basically the data store. But React has only one (uni) directional binding that means the data has only one source of truth that is the data store. Changing the data in view wouldn’t change anything unless the data in store is changed.</p><p>Data store in react is of two types:</p><ol><li>local state,</li><li>Global store ( redux or flux or mobx store ).</li></ol><p>Here state is nothing but a JS object which has all the data in the form of key value pairs.</p><p>If we want to persist state across pages ( containers in React ), we can use global store. Otherwise local state is good enough.</p><p><strong>So how does React and Node fit together ?</strong></p><p>Suppose we are building a Blog which will have crud functionalities and few pages like list of blog posts, contact us and blog post details page.</p><p>We will use Node/ Express in the backend and React in frontend.</p><p>Now React is just the view part of frontend. We have to store the data coming from backend api and also allow routing. For this purpose we will use React router and Redux. Actually we can get away with using Redux by creating 3 containers — Each for List of blog posts, contact us and blog post details. Each container will have their own data (local state) which won’t be shared with other containers.</p><p><strong>How does it work ?</strong></p><p>We will have a server side in express which is a framework of NodeJS.</p><p>In express we can declare routes for each pages we want. So we will have a</p><pre>homepage ( list of blog posts ) at path=’/‘,</pre><pre>details of a blog post at path=‘/:id’ and</pre><pre>contact us at path=‘/contact’.</pre><p>every route we define takes two params — request and response and has a callback function.</p><pre>app.get(‘/’, function(req, res) {</pre><pre>  res.send(‘Hello World’)</pre><pre>})</pre><p>Whenever a user visits the url mapped to path=‘/‘, a request is sent to the server and server returns the response in callback function. Inside the callback function, we can write our logic.</p><p>Similarly we can write functions for different paths.</p><pre>app.get(‘/:id’, function(req, res) {</pre><pre>  res.send(‘New Post’)</pre><pre>})</pre><p><strong>Where does React fit in the picture ?</strong></p><p>React handles the frontend of the app ( obviously ). Whenever user visits path=“/“, a request is sent to the express server which returns the response to the browser. Now in frontend, we have routers mapped to handle response coming from different routes and display the data. This is done using react router and react. Routers are required in frontend to load the appropriate components for each path as the backend server doesn’t care which component is loaded when user visits path=‘/‘. All it knows is what data to send when user visits a defined path.</p><p>React router just maps a path to a component.</p><pre>&lt;Route path=‘/‘ component={Homepage} /&gt;<br>&lt;Route path=‘/contact‘ component={Contact} /&gt;</pre><p>When we visit path=‘/‘, the homepage component will load.</p><p>After getting data from server in the form of JSON, we would like to display a list of blog posts. This can be done by creating a container in React ( say Homepage container )</p><p>A Component is a class or function that describes part of a React UI and Container is just a component which has access to state and lifecycle methods.</p><p>In Homepage container, we can create a function that will loop through the JSON and create a list of posts. It’s like a typical html page but written in JSX (which is weird looking cousin of html).</p><p>Data on sever side can be stored in any database ( MongoDB, firebase database ).</p><p>This is the gist of using Express in backend and React in frontend.</p><p><strong>Also What is NPM ?</strong></p><blockquote>Npm is a package manager through which one can install various packages ( modules ) needed for web development. It’s a CLI tool which gives access to it’s online repository which contains thousands of open-source Node.js projects.</blockquote><p>Getting started with npm is fairly simple. You just need to add a package.json file in your project and <a href="https://docs.npmjs.com/files/package.json#dependencies">mention all the dependencies</a> and run npm install from command line and it will install the packages. This is much better than manually downloading the libraries and copying them into the correct directories, and use them that way (something I used to do in the good ol’ days of bootstrap and jQuery).</p><p><a href="https://github.com/facebook/create-react-app">Create React App</a> is a very good boilerplate to get started with React.</p><p>For express, refer the <a href="https://expressjs.com/en/starter/installing.html">official docs</a>.</p><p><strong>Thanks for reading. Please comment if you want to learn more about React ecosystem.</strong></p><p><em>I use React, Redux, Redux Saga, React Router in my job everyday and I’m sure will be able to help you in someway.</em></p><p><strong>Reference: </strong>( I’m not the owner, just found them very well written)</p><p><a href="https://zellwk.com/blog/crud-express-mongodb/">https://zellwk.com/blog/crud-express-mongodb</a></p><p><a href="https://codeburst.io/getting-started-with-node-js-a-beginners-guide-b03e25bca71b">Getting Started With Node.js : A Beginners Guide</a></p><p>Checkout some of my other posts:</p><ol><li><a href="https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b">Why is customer acquisition a wrong metric to measure startup’s growth</a>.</li><li><a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">Named export vs default export</a>.</li><li><a href="https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2">What’s the difference between super and super(props) in ES6</a>.</li><li><a href="https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5">CurrentTarget vs Target in Js</a>.</li><li><a href="https://medium.com/@etherealm/getting-rid-of-relative-paths-in-imports-using-webpack-alias-78d4bf15bb42">Getting rid of relative paths in import statement using webpack aliases.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99b672262fed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Named Export vs Default Export in ES6]]></title>
            <link>https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/affb483a0910</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Sat, 17 Mar 2018 20:52:59 GMT</pubDate>
            <atom:updated>2020-04-27T07:59:55.016Z</atom:updated>
            <content:encoded><![CDATA[<p>ES6 provides us to import a module and use it in other files. Strictly speaking in React terms, one can use stateless components in other components by exporting the components from their respective modules and using it in other files.</p><p>ES6 provides two ways to export a module from a file: named export and default export.</p><p><strong>Named Export: (export)</strong></p><p>With named exports, one can have multiple named exports per file. Then import the specific exports they want surrounded in braces. The name of imported module has to be the same as the name of the exported module.</p><pre>// imports<br>// ex. importing a single named export<br>import { MyComponent } from &quot;./MyComponent&quot;;</pre><pre>// ex. importing multiple named exports<br>import { MyComponent, MyComponent2 } from &quot;./MyComponent&quot;;</pre><pre>// ex. giving a named import a different name by using &quot;as&quot;:<br>import { MyComponent2 as MyNewComponent } from &quot;./MyComponent&quot;;</pre><pre>// exports from ./MyComponent.js file<br>export const MyComponent = () =&gt; {}<br>export const MyComponent2 = () =&gt; {}</pre><p>Import all the named exports onto an object:</p><pre>import * as MainComponents from &quot;./MyComponent&quot;;<br>// use MainComponents.MyComponent and MainComponents.MyComponent2<br>here</pre><p><strong>Default Export: (export default)</strong></p><p>One can have only one default export per file. When we import we have to specify a name and import like:</p><pre>// import</pre><pre>import MyDefaultComponent from &quot;./MyDefaultExport&quot;;</pre><pre>// export</pre><pre>const MyComponent = () =&gt; {}</pre><pre>export default MyComponent;</pre><p>The naming of import is completely independent in default export and we can use any name we like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*DV9TTNn2JZJKDyCESmElvQ.gif" /><figcaption>we can use made up names but keep it relevant.</figcaption></figure><p>From <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export">Documentation</a>:</p><blockquote>Named exports are useful to export several values. During the import, one will be able to use the same name to refer to the corresponding value.</blockquote><blockquote>Concerning the default export, there is only a single default export per module. A default export can be a function, a class, an object or anything else. This value is to be considered as the “main” exported value since it will be the simplest to import.</blockquote><p>Checkout my other posts:</p><ol><li><a href="https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b">Why is customer acquisition a wrong metric to measure startup’s growth</a>.</li><li><a href="https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2">What’s the difference between super and super(props) in ES6</a>.</li><li><a href="https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5">CurrentTarget vs Target in Js</a>.</li><li><a href="https://medium.com/@etherealm/node-and-react-a-brief-introduction-99b672262fed">A brief introduction of Node, React and NPM</a>.</li><li><a href="https://medium.com/@etherealm/getting-rid-of-relative-paths-in-imports-using-webpack-alias-78d4bf15bb42">Getting rid of relative paths in import statement using webpack aliases.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=affb483a0910" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CurrentTarget vs Target in Js]]></title>
            <link>https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f3fd3a543e5</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 11:39:30 GMT</pubDate>
            <atom:updated>2020-04-27T08:00:42.755Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>What is the difference between event.currentTarget and event.target in JS ?</blockquote><p>If you are interviewing for a frontend developer role, there is a high chance that you maybe asked this question.</p><p>So what exactly are these and where would you use them ?</p><p>To understand that we need to understand what are events and how they occur in JS.</p><p>Interaction of User with the dom is known as events. Clicking of buttons, hovering of mouse over an element, pressing of any keys are all events.</p><p>Whenever these events occur we would like to run some JS function which is done using event handlers.</p><p>Now every event goes through three phases of event propagation: <br>1. From window to the target element phase.</p><p>2. The event target phase and</p><p>3. From the event target back to the window phase.</p><p>event.currentTarget tells us on which element the event was attached or the element whose eventListener triggered the event.</p><p>event.target tells where the event started.</p><p>Suppose there’s an event which shows an alert on click of the element. This event has been attached to the body. Now when the user clicks on the strong tag, currentTarget(.nodeName) will show the body whereas target will show strong as the alert output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*5hQXYRcO057rQKJUpcnO5w.gif" /></figure><pre>&lt;body onclick=”myFunction(event)”&gt;</pre><pre>&lt;p&gt;Click on a paragraph. An alert box will alert the element whose eventlistener triggered the event.&lt;/p&gt;</pre><pre>&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The currentTarget property does not necessarily return the element that was clicked on, but the element whose eventlistener triggered the event.&lt;/p&gt;</pre><pre>&lt;script&gt;<br>  function myFunction(event) { <br>    alert(event.currentTarget.nodeName); // body<br>    alert(event.target.nodeName); // strong<br>  }<br>&lt;/script&gt;</pre><p>Links:</p><p><a href="https://www.sitepoint.com/event-bubbling-javascript/">Event Bubbling</a></p><p>Checkout my other posts:</p><ol><li><a href="https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b">Why is customer acquisition a wrong metric to measure startup’s growth</a>.</li><li><a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">Named export vs default export</a>.</li><li><a href="https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5">CurrentTarget vs Target in Js</a>.</li><li><a href="https://medium.com/@etherealm/node-and-react-a-brief-introduction-99b672262fed">A brief introduction of Node, React and NPM</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f3fd3a543e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between super() and super(props) in constructor of a React Class Component ?]]></title>
            <link>https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2?source=rss-513e9f637f42------2</link>
            <guid isPermaLink="false">https://medium.com/p/58658af6ecf2</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Alankar Anand]]></dc:creator>
            <pubDate>Mon, 22 Jan 2018 20:16:07 GMT</pubDate>
            <atom:updated>2020-04-27T08:01:01.997Z</atom:updated>
            <content:encoded><![CDATA[<p>When creating Class Components in React, we often call super in the constructor of the Component and also pass in props to it. But do we really need to do this ? I mean pass props to super.</p><p>Well, React Documentation recommends —</p><blockquote>Class components should always call the base constructor with props.</blockquote><p>and ES6 Classes have to call <em>super</em> if they are subclasses.</p><p>But why pass props to super ? It’s because if we want to use <em>this </em>in the constructor, we need to pass it to super.</p><pre>class MyComponent extends React.Component {<br>  constructor(props) { <br>    super();<br>    console.log(this.props); // undefined<br>    console.log(props); // defined<br>  }</pre><pre>render() {<br>    return &lt;div&gt;Hello {this.props.message}&lt;/div&gt;; // defined<br>  }<br>}</pre><p>However if we use <em>super(props)</em></p><pre>class MyComponent extends React.Component {<br>  constructor(props) { <br>    super(props);<br>    console.log(this.props); // props will get logged.<br>  }</pre><pre>render() {<br>    return &lt;div&gt;Hello {this.props.message}&lt;/div&gt;; // defined<br>  }<br>}</pre><p>So, to conclude, If you want to use this.props inside constructor, you need to pass it in super, otherwise it’s okay to not pass props to super as we see that irrespective of passing it to super, this.props is available inside render function.</p><p><strong>Credits:</strong><br>You can check out this awesome stackoverflow discussion for more details:<br><a href="https://stackoverflow.com/questions/30571875/whats-the-difference-between-super-and-superprops-in-react-when-using-e">https://stackoverflow.com/questions/30571875/whats-the-difference-between-super-and-superprops-in-react-when-using-e</a></p><p>Checkout my other posts:</p><ol><li><a href="https://medium.com/@etherealm/threshold-a-measure-of-startups-growth-b53d8ca8764b">Why is customer acquisition a wrong metric to measure startup’s growth</a>.</li><li><a href="https://medium.com/@etherealm/named-export-vs-default-export-in-es6-affb483a0910">Named export vs default export</a>.</li><li><a href="https://medium.com/@etherealm/currenttarget-vs-target-in-js-2f3fd3a543e5">CurrentTarget vs Target in Js</a>.</li><li><a href="https://medium.com/@etherealm/node-and-react-a-brief-introduction-99b672262fed">A brief introduction of Node, React and NPM</a>.</li><li><a href="https://medium.com/@etherealm/getting-rid-of-relative-paths-in-imports-using-webpack-alias-78d4bf15bb42">Getting rid of relative paths in import statement using webpack aliases.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58658af6ecf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>