<?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[wineofbits - Medium]]></title>
        <description><![CDATA[A wine made out of the experience for knowledge-thirsty people. - Medium]]></description>
        <link>https://medium.com/wineofbits?source=rss----48af64ece580---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>wineofbits - Medium</title>
            <link>https://medium.com/wineofbits?source=rss----48af64ece580---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:45:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/wineofbits" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Designing a Distributed Rate Limiter — Deep Dive]]></title>
            <link>https://medium.com/wineofbits/designing-a-distributed-rate-limiter-deep-dive-76d7e8d8452d?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/76d7e8d8452d</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[system-design-project]]></category>
            <dc:creator><![CDATA[Hiresh Trivedi]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 15:55:15 GMT</pubDate>
            <atom:updated>2021-08-04T15:55:15.714Z</atom:updated>
            <content:encoded><![CDATA[<h3>Designing a Distributed Rate Limiter — Deep Dive</h3><h3>Pre-requisite</h3><p>This article follows <a href="https://medium.com/@hiresh.at/designing-a-distributed-rate-limiter-introduction-731afd345a66">Designing a distributed rate limiter — Introduction</a>. The beginning might seem abrupt if the first article is skipped.</p><p>We now have the motivation to implement a rate limiter, discussed many questions that might arise before implementing rate limiters, and had a look at real-world examples where rate limiters saved the day and examples of existing services using rate limiters. We can now have a deep dive into implementation details.</p><h4>Where to place rate limiter in your architecture?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQXK30B3gxgYAQL-KVTy5A.png" /><figcaption>Image courtesy : Microsoft cloud architecture guide</figcaption></figure><p>We can place it in API Gateway, as an external service, or inside your application server. Mostly a matured architecture would be using an API gateway for authentication, IP whitelisting, SSL termination, etc. If we have sufficient control on API gateway we can have our rate limiter inside API Gateway and have a fallback mechanism because they can fail too (<a href="https://searchunifiedcommunications.techtarget.com/news/252495267/Massive-Slack-outage-caused-by-AWS-gateway-failure"><em>Slack outage because of AWS gateway failure</em></a>).</p><p>If we do not want to commit forever to API gateway and decouple rate limiter service we can place it as an external service after API gateway.</p><p>It is important to address the urge to place rate limiter in application container using <a href="https://medium.com/nerd-for-tech/microservice-design-pattern-sidecar-sidekick-pattern-dbcea9bed783">sidecar pattern</a>, arguing that if a threshold is violated we do not proceed with sending requests to the database, cache, or other services, thereby effectively getting rid of invalid requests in less time and not overworking application server, but this defies the core principle of keeping application servers alienated from such requests, to begin with, and thereby allowing more <em>valid</em> user requests to reach our application servers.</p><p>Based on tech stack, control on API gateway, and infrastructure we can decide placing rate limiter at the appropriate level, however, it will be tough to find substantial cons for having a separate service of rate limiter after API gateway.</p><h4>Algorithms to implement rate limiting logic</h4><p>We have various options to select the underlying algorithm, some of them are</p><ul><li>Token bucket algorithm</li><li>Leaky bucket algorithm</li><li>Sliding window counter</li><li>Fixed window counter</li></ul><p>Token bucket algorithm is arguably the most widely used algorithm, we will discuss about Token Buckets here, exclusion of other algorithms here is intentional to keep article brief.</p><h4>Token Bucket Algorithm</h4><p>Identifiers can be user, IP, API path, or any other entity we wish to track request count for.</p><p>we specify 2 parameters :</p><ol><li>Bucket size (maximum number of requests allowed for an identifier)</li><li>Refill rate (refill the bucket with bucket size at every X seconds)</li></ol><p>At each incoming request we check the remaining number of tokens of the identifier, if the remaining number of tokens is above the permitted threshold in the rule, we allow the request else we drop it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*heqi5WacHpyT8fKdvyDmrQ.jpeg" /></figure><p>Finally we schedule a timer that refills the bucket with specified tokens after a constant time interval.</p><h4>Where are the rules to limit requests stored?</h4><p>We will need a specification for threshold of requests allowed for each identifier that gives information like</p><ol><li>How many times a user is allowed to access a premium content for free?</li><li>How many tweets per second a user can tweet?</li></ol><p>There are existing rate limiters which store such configuration in files, we can also have a in-memory cache storing these rules given that these rules wont change frequently.</p><h4>How are the availed request counters for each identifiers stored?</h4><p>We will need to store available tokens for each identifier and update the number of tokens on each identifier request so that when it hits its limit we can identify the same. This seems to be an important decision.</p><p>Using a database might not be the best decision here because of the disk reads, storing the counters in a persistent cache like Redis with inbuilt features like <em>INCR </em>and<em> EXPIRE </em>can substantially reduce latency.</p><h4>How does a client know it is being throttled?</h4><p>Clients can also handle rates at which they send requests if informed about limits. Certain HTTP response headers can be used to achieve this :</p><ol><li><em>X-Ratelimit-Remaining</em>: remaining number of allowed requests in the window</li><li><em>X-Ratelimit-Limit</em>: number of calls client can make in time window</li><li><em>X-Ratelimit-Retry-After</em>: number of seconds to wait</li></ol><p>and others that can help client react accordingly.</p><p>We can now visualize our design as pictured below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bcdcls-gRI3jKBy8HdtJbQ.jpeg" /></figure><h4>Rate limiter in distributed environment</h4><p>Now that we have the design represented in a way that we can scale it further, we need to anticipate any problems that we could face in distributed environment.</p><h4>Synchronization problem or consistency issues</h4><p>Consistency of data might not be maintained if second request of the user comes before the first update is propagated to all the nodes.</p><p>To demonstrate the problem, consider the following events in order</p><p>0. Rule for user — maximum 4 requests allowed per second.</p><ol><li>‘User 1’ sends request to Rate limiter server “A”</li><li>Server “A” updates the counter in <strong>its</strong> Redis cache node, number of tokens is now 3 (was previously 4).</li><li>The same ‘User 1’ again sends request but to server “B” whose Redis cache instance does not have the updated count for this user (user 1), makes the counter 3 (should be 2).</li></ol><p>One solution is to use sticky sessions, the user sends the requests to the same server, but this is not fault-tolerant, and adding or removing servers will cause issues, it is mostly recommended to go for stateless web-tier.</p><p>We can use locks and use gossip protocol to propagate the change to other servers so that when the next request comes every node has updated data, this will increase the inter-service communication and thereby increase latency.</p><p>We can instead have a centralized Redis store and have all the rate limiter servers reach out to the same centralized store, but this does not scale well. Our rate limiter nodes can overwhelm the centralized Redis store.</p><p>As we see, with these approaches we either compensate consistency for low-latency or its inverse.</p><p>We can shard the Redis store based on the identifier and route the requests to the Redis store that has the details for this identifier. This will solve the issue of consistency since requests of a particular identifier will reach only the concerned Redis store and low latency is achieved because there are multiple rate limiter servers. What if a shard fails? We might lose the data for a set of the identifiers, hence we maintain replicas, this is will give us a good balance of low-latency, fault tolerance, and consistency (eventual consistency).</p><p>For possible race conditions please refer to an interesting solution — <a href="https://engineering.classdojo.com/blog/2015/02/06/rolling-rate-limiter/">Better rate limiting with Redis sorted sets</a></p><p>We should now have a decent idea on features, implementation details and high level design of rate limiters and we are now equipped with the basic concepts that can help us find answers if any further curiosity on the topic arises.</p><p>I wish medium had a feature where all the embedded links could be listed at one place in the article, there are some interesting links added in both of my articles, consider this as a reminder to visit them if they were overlooked earlier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76d7e8d8452d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/designing-a-distributed-rate-limiter-deep-dive-76d7e8d8452d">Designing a Distributed Rate Limiter — Deep Dive</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Distributed Rate Limiter — Part 1]]></title>
            <link>https://medium.com/wineofbits/designing-a-distributed-rate-limiter-introduction-731afd345a66?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/731afd345a66</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[system-design-project]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <dc:creator><![CDATA[Hiresh Trivedi]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 15:54:08 GMT</pubDate>
            <atom:updated>2021-08-05T06:41:27.599Z</atom:updated>
            <content:encoded><![CDATA[<h3>Designing a Distributed Rate Limiter — Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*pgJ3Lbla7d_mj25Ve-bs1Q.jpeg" /><figcaption>Neo from matrix limiting bullets</figcaption></figure><h4>What is Rate Limiter?</h4><p>Imagine you have deployed a public API and the users are crazy about the product, it could be</p><ol><li>URL shortening</li><li>Getting the nearest pizza store from the user’s location</li><li>Getting the statistical analysis of a stock</li></ol><p>But you do not have …</p><p>A middleware that can control the rate of the traffic that is being sent to your web servers based on flexible rules. If the specified threshold is violated, it drops or enqueues the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*smqvRy2wWXtZnXeidHE5oQ.png" /><figcaption>Image credit : <a href="https://www.tibco.com/sites/tibco/files/media_entity/2021-04/rate-limiting-diagram.svg">https://www.tibco.com/sites/tibco/files/media_entity/2021-04/rate-limiting-diagram.svg</a></figcaption></figure><p>This rules out malicious requests that can overwork your servers and enable you to distinguish organic requests from automated ones by identifying users’ accounts or IPs that are violating specifications for your API rate limits.</p><h4>Why designing a Rate Limiter is interesting?</h4><p>It is interesting mainly for its span of problems across breadth and depth that it solves while also preventing a DDoS attack. Rate limiters can be used,</p><ol><li>For the client applications of your trading system: allow each client app to only send 5 orders per second</li><li>Throttle number of rewards on payment platform per user per month, or/and a global limit on rewards per user</li><li>For platforms like Medium: allow non-premium users to access only 3 premium stories per month</li><li>Early Fraud detection if possible can be dropped from middleware before reaching the web servers</li></ol><p>As it appears, it needs to handle cases of persisting states of available access counters for months and needs to handle data-intensive bursts of requests with low latency.</p><p>There also can be cases where access restrictions are ‘soft’, eventually serve requests but do not send requests to web servers right away if rules are violated (throttle), adding requests to a queue will also open gates for a back-pressure scenario where your queue is overwhelmed.</p><p>We talk about server-side rate limiters here, but clients can also have rate limiters in place before sending out requests to servers.</p><p>It is also good to know that OWASP security top 10 has a lack of rate limiter at number 4. It’s very pleasing to have a solution that not only secures your service but also improves performance and user experience.</p><h4>Why not just look up docs and use an existing popular rate limiter?</h4><p>Given that the problems rate limiters solve are faced in almost every large-scale distributed system, there are a lot of rate limiters that can do the job.</p><ul><li><a href="https://www.socialmediatoday.com/news/twitter-says-its-smyte-acquisition-has-helped-it-significantly-reduce-crypt/557524/">Smyte (acquired by Twitter) reduced the crypto-scams</a> on Twitter to 5000 per day from 1 million per day by limiting the scam tweets. <a href="https://github.com/smyte/ratelimit">Its Rate limiter</a> is not the core application here but it is crucial for achieving this.</li><li><a href="https://www.youtube.com/watch?v=rZ8mhTMDoCU">Dealing with 30 Million requests</a> using Rate limiting features of <a href="https://github.blog/2021-04-05-how-we-scaled-github-api-sharded-replicated-rate-limiter-redis/">Redis</a></li><li><a href="https://eng.lyft.com/announcing-ratelimit-c2e8f3182555">Lyft had open-sourced its Rate limiter</a> back in 2017.</li></ul><p><a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html">Amazon uses Token Bucket Algorithm</a> to limit requests, so does Stripe. Some say <a href="https://medium.com/@animirr/fixed-window-rate-limiter-is-slightly-better-than-token-bucket-here-is-why-bc769c0bdd9">a fixed window algorithm is better</a>.</p><p>And many more solutions, that can get you going in no time, however, it is very crucial to understand basic working mechanisms and know challenges to anticipate for each of them, with more choices comes the problem of choosing the most suitable choice.</p><p>Hence the scope of this series is to give a detailed account of the design of Rate limiting systems, algorithms used to achieve rate limiting, and CAP challenges in a distributed system.</p><h4>Why not just use server configuration parameters to limit requests?</h4><p>Parameters like max connection and max thread count can tune requests but our requirement simply is a bit customized, these parameters have no knowledge about the user interaction with application logic, imagine if few clients cover the max number of requests threshold, other users will have to simply wait even when existing requests are not justified.</p><p>Load balancers will also distribute requests in round-robin or based on current server load and be agnostic about the application logic on throttling and latency potential of the request.</p><h4>Should we not auto-scale our infrastructure to accommodate all the requests?</h4><p>Apart from the charges that auto-scaling will incur, it is not an instant process, it will still be a possible outage situation while the nodes are added, registered in service discovery and consensus is established on leader, the request rate will have to be insane for this scenario, which typically is… for a worldwide popular service. Snippet from a slack outage report might help.</p><blockquote>The large number of broken instances caused us to hit our pre-configured autoscaling-group size limits, which determine the maximum number of instances in our web tier.</blockquote><blockquote>we couldn’t provision new dashboard service instances because provision-service was overloaded.</blockquote><p>Rate limiters can also control the rate of low priority requests of API and high priority requests, allowing you to drop low priority requests if there are some internal issues and serve high priority requests.</p><h4>Sounds like the rate limiter will be a performance bottleneck since it will check every incoming request, who will limit the requests to the rate limiter?</h4><ul><li>Rate limiter will be deployed in a distributed system, we have multiple nodes of rate limiters receiving requests from load balancer (<a href="https://stackoverflow.com/questions/55201050/what-can-we-do-when-load-balancer-becomes-the-bottleneck">Load Balancer is not a bottleneck because of DNS Load Balancing</a>)</li><li>The number of rate limiter nodes will not be as high as application server nodes as the rate limiter’s capacity to handle requests is substantially higher as it’s not a high latency operation as we will see in our next article.</li></ul><p>The preface, as lengthy as it is, serves the purpose of clarity on deciding when to use a rate limiter and the scenarios that it serves best. We do not want to document, build and test a middleware when we are better off without it or find out that we could have done better. We can now happily proceed to discuss details. <a href="https://medium.com/@hiresh.at/designing-a-distributed-rate-limiter-deep-dive-76d7e8d8452d">Designing a rate limiter — Deep Dive</a></p><p><a href="https://medium.com/wineofbits/designing-a-distributed-rate-limiter-deep-dive-76d7e8d8452d">Designing a Distributed Rate Limiter — Deep Dive</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=731afd345a66" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/designing-a-distributed-rate-limiter-introduction-731afd345a66">Designing a Distributed Rate Limiter — Part 1</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advice to freshers on preparing for an interviews]]></title>
            <link>https://medium.com/wineofbits/advice-to-freshers-on-preparing-for-an-interviews-9e23eacb46ac?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/9e23eacb46ac</guid>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Sat, 17 Apr 2021 14:03:06 GMT</pubDate>
            <atom:updated>2021-05-01T17:24:08.917Z</atom:updated>
            <content:encoded><![CDATA[<h3>Advice to computer science freshers on preparing for interviews</h3><h4>Ever wondered what it takes to land an amazing job at good companies as a fresher?</h4><figure><img alt="Person giving a paper to a coder" src="https://cdn-images-1.medium.com/max/1024/1*hFnB37CfQ6D5mGfZQcLO0w.png" /><figcaption>Advice</figcaption></figure><p>I had started as a fresher, worked on creating python web crawlers, implemented single sign-on to replace the legacy sign in and authorization for 40 websites, creating POCs for different clients for their startups, working on low latency distributed systems as a full stack developer, and taking interviews for different positions.</p><p>At multiple points in time, I have had the thought that if I knew this when I was a fresher, I could have avoided the hard work. I would have achieved the same result faster.</p><h3>Interviewer’s perspective</h3><p>We have done all kinds of preparation for the interview as a fresher. We write many projects and technologies in our resumes to make them attractive. We find the fanciest resume templates.</p><p>But we forget the most important aspect of the interview.</p><p>When you look from the interviewer’s perspective, they have bare minimum expectations from freshers. The bare minimum is nothing but a good foundation of computer science knowledge. If you completed your master’s then the focus would be on the specialization and your thesis.</p><p>If you know this then you can crack any interview as a fresher.</p><h3>The good foundation</h3><p>There are two types of good freshers. One can prepare based on their interest. The first point describes the two types. The second point is a must for both.</p><ol><li>Good DSA or Good exposure/ versatility</li><li>Problem solving and Communication</li></ol><h4>What is good DSA?</h4><figure><img alt="Visual representation of stack, queue, map, and one flow chart to describe algorithm" src="https://cdn-images-1.medium.com/max/647/1*_dEKTmyTHSfrgfVbGxCVhQ.png" /><figcaption>Queue, Stack, Map, Flowchart</figcaption></figure><p>Computer science is a very broad field and not everybody wants a software engineer for research. As a result, most companies need people that have good fundamentals: data structure, algorithm, and problem-solving.</p><ol><li>Data structures</li><li>Algorithm</li></ol><h4>Data structures</h4><p>To develop the software one must know what are the advantages and disadvantages of different data structures. When one should use a stack, queue, or map. When to use a hashmap&lt;String, List&gt; or an array of queues or a set. This can only be known when you have a good understanding of all the basic data structures.</p><p>While learning any DS, focus on these points: How to use it, how can you build your implementation of the same, See its example usages.</p><p>Learn its performance/time complexity for different operations and based on that you can decide, which DS to use in your specific use case.</p><p>For example, Imagine that your user will enter a company’s unique id and you have to return all the information about that company from your DB. Then querying the DB each time is very costly. A map has key-value pairs and has an access of O(1) so we can create a cache of say 1k companies in a map&lt;unique id, company information&gt;. Now our application will be much faster but storing only 1k won’t be enough as there can be thousands of companies in our DB.</p><p>If the entry is not present in our cache then we can query the DB and return the result. How do choose which companies to keep in our map such that we have minimal cache misses? If our users are dynamic and search for different companies based on different conditions then we have to come up with a better strategy for choosing the right companies.</p><p>One such strategy can be making our map hold 1k entries of the recently used companies. If an entry is not present in our cache then we query the DB and update our cache by putting this new item in the hashmap and removing the least used company. Now for example, if some big news came mentioning “Microsoft” and our app is a trading app then many users would search for it. With our current strategy, our cache will have that entry thus saving the DB hit keeping up with the request load. This can be build by combining our existing map with a linked list to maintain the queue of the least recently used companies. This is nothing but an LRU cache and if you want to try building this cache yourself then try it here on <a href="https://leetcode.com/problems/lru-cache/">leetcode/problems/lru-cache</a>.</p><p>For more practice, go to any of the competitive coding platforms and solve some problems for each data structure.</p><p>List of data structures to learn:</p><ul><li>Array</li><li>Linked list</li><li>Stack</li><li>Queue</li><li>Map</li><li>Tree</li><li>Heap</li><li>Hashing</li><li>Graph</li></ul><h4>Algorithm</h4><p>Understand the working of an algorithm, learn where it can be used, and the preconditions required to use it. For example, binary search requires the elements to be sorted first. Focus on the algorithm itself and think about how you would implement it in any language given you know the syntax. Remember the corner cases for each algorithm as well. i.e. ways to handle the worst-case scenario of quicksort. Understand the time complexity of the algorithm and learn how to derive it for any algorithm.</p><p>List of algorithms to learn:</p><ul><li>Sorting (Selection sort, Bubble, Insertion sort, Merge sort, Quick sort, Heap sort, and Bucket sort)</li><li>Search (Linear search, Binary search)</li></ul><p>An algorithm is just a generic term to define the solution to any problem. So when you will practice more solving competitive coding questions then you will be able to find an algorithm for any problem.</p><p>There are various paradigms in algorithms through which one can solve a problem. Understand these paradigms and how they work. Practice few problems where a particular paradigm can be used to build the instinct for when to use what. Many problems can be solved in multiple ways but once you do some practice, you will build an instinct similar to how we can solve polynomial equations in mathematics or understand certain drawing techniques after some practice. I have listed down the types of paradigms here with some famous problems to practice.</p><ul><li>Greedy algorithms (Activity selection problem, Kruskal’s and Prim’s Minimum spanning tree, Dijkstra’s shortest path, Job sequencing problem, Minimum number of coins)</li><li>Brute force (One can try to solve any problem by brute force and then improve upon it.)</li><li>Backtracking (Sudoku solver, <a href="https://leetcode.com/problems/n-queens-ii">N queens</a>)</li><li>Dynamic Programming (Coin change, Matrix multiplication, Knapsack problem, Floyd Warshall, Bellman-Ford)</li><li>Divide and conquer (Merging n sorted or unsorted lists in a single sorted list, Maximum subarray)</li><li>Two pointers (Not a paradigm but we can solve multiple problems with this strategy, i.e. two sum problem.)</li></ul><h3>What is good exposure or versatility?</h3><figure><img alt="Logos of various frontend libraries, backend libraries, and dbs" src="https://cdn-images-1.medium.com/max/890/1*3rT7mRR2QTu8hFtvZulj_Q.png" /><figcaption>Various techs and tools</figcaption></figure><p>If you are a maker and like to work on projects instead of solving DSA problems then create more than 3 projects from scratch and understood them from line to line. Choose your own tech stack by researching which techs would best suit your app. Why did you choose this tech stack will be one of the questions a recruiter can ask.</p><p>Understands how a frontend communicates with a backend? Get yourself familiar with REST, SOAP, Websocket, SSE, Long polling, and GraphQL.</p><p>For example, most of the applications have separate frontend and backend servers. Let’s say our application uses React in the frontend and uses spring boot server and MySQL DB in the backend. Now React uses JS to render the UI in the user’s browser dynamically. It will show one login/signup page in the browser but when the user enters these details, it will call the backend REST/SOAP API or GraphQL mutation. It does this by making an HTTP request to your server. Now the backend server receives whatever parameters we sent in the respective controller and performs business logic such as verifying the username/password or create a new user. For this, it communicates with our DB also and then returns the respective response. The frontend uses this response to update the UI.</p><p>Learn the difference between Authentication and Authorization. For starters, learn how the JWT token works. How can you use it to implement authentication and authorization? Depending on your path, you can try to implement authorization in the frontend and the backend.</p><p>If you want to be a backend developer then you should be able to create APIs, work with DBs, understand the authentication and authorization.</p><p>While working with DBs see if you can create one project with a SQL DB and another project with a NoSQL DB. Then compare them and understand when to use what.</p><p>If you want to be a frontend developer then learn any frontend framework such as React/ Angular/ Vue and you should be able to design some screens, components, communicate with backend APIs via Rest. If you could learn WebSocket also then it is an added point. Learn the difference between different storage mechanisms available and when to use what.</p><p>People who are confused about where they want to work can start with being a full-stack developer and then see where they are comfortable.</p><p>For ML developers, I do not have much exposure but you can learn the bare minimum required like knowing the available tools and models in the market, how to use them, and where can you use them. Given a scenario if you could figure out how would you get the raw data, what would the data content mean, which model would you use, how will you test it, and then how will you improve your solution for better accuracy. If you could answer some of these questions then it is enough. The more you can cover, the better.</p><p>No one path is better than the other but their importance changes based on the company and project you are working on. So whatever path you choose is fine.</p><p>Create a decent Github profile and get yourself familiar with a bit of version control. Create separate repos for each of your projects and push your changes. Now add these URLs to your resume. The recruiter likes to look at your code than just a text explanation of the project. But when you do this also be prepared to answer questions about those projects. Imagine if you had to understand this project from scratch then what questions would come to your mind after reading the code and description of your project. These are the questions that the interviewer will ask you.</p><h4>Problem solving and Communication</h4><p>Irrespective of the type of skills you have, if you can’t solve a problem with these skills then it is of no use. Practice how to approach different types of problems. In an interview, think out loud so that your interviewer knows how you are approaching the problem. If they know what you are thinking then they can guide you. This also shows your communication skills and while working in a team, effective communication is very important. Programming is also nothing but communicating to the machine what do you want to do. So once you know the solution to a problem, learn how to convert them into a program.</p><h3>Values</h3><p>What are your values as an individual? Find them and stick to them in the tough time. It can be anything as simple as honesty, truth, or equality. For example, my values are Kaizen, Introspection, Transparency, and Semantics. Imposter syndrome and FOMO are real things. Everyone feels the same fears so have faith in yourself, stay flexible, and keep on learning. Positively accept the feedbacks, they are to make yourself better only.</p><h3>Hobbies</h3><p>Have some hobbies or passion for something else other than just coding. It will help you grow both professionally and personally. It will give you something you can invest your time in, your therapeutic gateway far away from your daily work. It shows that you do not just care about monetary things and it also helps you increase your network. This will help you in long run.</p><p>Happy coding and May the force be with you.</p><p>P.S. If you found this article helpful, clap! 👏👏👏 It feels rewarding and gives me motivation to continue my writing. If you have any suggestion then let me know. We will improve this article together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e23eacb46ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/advice-to-freshers-on-preparing-for-an-interviews-9e23eacb46ac">Advice to freshers on preparing for an interviews</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NodeJS basics 101]]></title>
            <link>https://medium.com/wineofbits/nodejs-basics-101-3f59b9a7222b?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f59b9a7222b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 20:01:00 GMT</pubDate>
            <atom:updated>2019-02-26T12:15:31.014Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h4>A runtime environment, not a language!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jw9V__6jYhm2amP74D_0lw.png" /><figcaption>NodeJS Logo</figcaption></figure><p>NodeJS ecosystem is very big and it is still growing day by day. It is an <strong><em>asynchronous event driven environment</em></strong> that uses google’s v8 engine to run javascript. V8 is the same engine used in google chrome to run JavaScript.</p><blockquote>NodeJS can also use chakra(developed by microsoft) or spidermonkey(by Mozilla). But Node uses V8(by google) as of now. Due to this competition, we get better engines each year so yay!</blockquote><p>As it is asynchronous in nature, you should be able to leverage or handle it efficiently. So I highly recommend that once you finish this guide, you read about callback hell and promises.</p><p>This article will focus on covering the tools that will help you as a beginner to better understand the environment. Hovever, if you’re already a NodeJS developer then you might already know these.</p><p>The official docs explains NodeJS very efficiently in a concise manner. If you’re interested then give it 5 minutes of your time.</p><p><a href="https://nodejs.org/en/about/">Node.js - About Node.js®</a></p><blockquote>It should be clear now that NodeJS is a runtime environment, not a language. Javascript is the language which is used to program in NodeJS.</blockquote><blockquote>Javascript also has many varients but that is another topic.</blockquote><h4>NVM: Installing and managing node versions effortlessly</h4><p>To use NodeJS, one has to actually install it and many times in a particular project, you have to use specific version of NodeJS. So first thing to do is install NVM.</p><p>Don’t be afraid to read the instructions from plain markdown text.</p><p><a href="https://github.com/creationix/nvm#installation-and-update">NVM: Installation</a></p><h4>Use nodemon while developing nodeJS apps</h4><p>When you’re developing the application then you have to restart the script each time if you use node app.js This is very cumbersome for debugging and developing. So use <a href="https://nodemon.io/">Nodemon,</a> it restarts the server automatically whenever you make changes to your files.</p><p>To install it globally and start the app, use below commands,</p><pre>npm install -g nodemon<br>nodemon app.js</pre><h4>Know your logs better!</h4><p>One of the most important tool for a developer are logs. Even in production, we need logs to monitor and log important information. Checkout the guide given by risingstack.</p><p><a href="https://blog.risingstack.com/node-js-logging-tutorial/">How to Get Node.js Logging Right | @RisingStack</a></p><h4>Difference between module.exports and exports?</h4><p>It is very likely that you will create your project in a modular fashion. So you will be creating multiple files and exporting different functions. To export it, you will use exports object.</p><p>module is a plain JavaScript object with an exports property. exports is a plain JavaScript variable that happens to be set to module.exports. At the end of your file, node.js will basically &#39;return&#39; module.exports to the require function. A simplified way to view a JS file in Node could be this:</p><pre>var module = { exports: {} };<br>var exports = module.exports;<br>// your code<br>return module.exports;</pre><p>If you set a property on exports, like exports.a = 9;, that will set module.exports.a as well because objects are passed around as references in JavaScript, which means that if you set multiple variables to the same object, they <em>are</em> all the same object; so then exports and module.exports are the same object.<br> But if you set exports to something new, it will no longer be set to module.exports, so exports and module.exports are no longer the same object.</p><p>This great explanation was provided by an <a href="https://stackoverflow.com/a/16383925/5027712">amazing developer goto-bus-stop</a>.</p><p>So if you do something like exports={getUserById:getUserById}. It won’t work and you won’t get anything when you try to import it. while exports.getUserById = getUserById will work.</p><h4>What is Event Loop?</h4><p>I urge you to go through this video and know what exactly is an Event Loop. Please go through this. It is very important that I am saying this again and again. It will clear many things and give you Aha moments!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8aGhZQkoFbQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8aGhZQkoFbQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8aGhZQkoFbQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/204a98bf5f658b677a94bd62e0d85854/href">https://medium.com/media/204a98bf5f658b677a94bd62e0d85854/href</a></iframe><h4>NodeJS ECMAScript features</h4><p>This might not be useful to you immediately but if you know then it will come in handy in future.</p><p>You may want to use particular feature of ECMAScript and different versions of NodeJS ships different features. You can check the API docs for information on which features are supported by each version. But if you don’t want to go through the docs just to get the YES/NO answer like me, then Check this website to quickly track the progress of each feature.</p><p><a href="https://node.green/">https://node.green</a></p><p>As of this writing the current LTS version is 10.15.1, Latest stable version is 11.10 and Nightly build version is 12.</p><p>Thank you for reading.</p><p>Please leave comments if you have any suggestion/s or would like to add a point/s or if you noticed any mistake/typos!</p><p>P.S. If you found this article helpful, clap! 👏👏👏 [feels rewarding and gives the motivation to continue my writing].</p><h4>Bonus</h4><p><a href="http://exploringjs.com/es6/ch_core-features.html#ch_core-features">Javascript ES6 core features</a></p><p><a href="https://javascript.info/promise-basics">Guide to Promises</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f59b9a7222b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/nodejs-basics-101-3f59b9a7222b">NodeJS basics 101</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Virtual Scroll in Angular to boost the website performance]]></title>
            <link>https://medium.com/wineofbits/how-to-use-virtual-scroll-in-angular-to-boost-the-website-performance-ed2d543be41c?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed2d543be41c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[infinite-scroll]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Priyank Gajera]]></dc:creator>
            <pubDate>Thu, 06 Dec 2018 12:01:00 GMT</pubDate>
            <atom:updated>2018-12-06T12:01:00.884Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHixp0ytsi4BnuKKRIlzFg.jpeg" /><figcaption>Angular + Virtual Scroll</figcaption></figure><p>Performance of the website is a vital part of the development lifecycle. Nowadays, the user needs a website to respond quickly and they are going to leave the website if they have to wait for even 3-5 seconds.</p><p>Well, if the website has too much data then it will be foremost that when we show everything, the performance of the website will degrade. As it’s obvious that if the website has huge data then DOM elements are also going to be huge and it will degrade the performance of the website. If a webpage is long then the browser will also create DOM elements which are not visible to a user and appear when they scroll down resulting in bad user experience. So what can we do about this? what if we generate only DOM elements that are visible to the user?</p><p>We can do it with lazy loading and it is a good option for the performance optimization but it requires more development efforts. So what if we only implement lazy loading kind of behaviour in frontend itself so it will also reduce the API calls to fetch the data. We can do that in the frontEnd without implementation of lazy loading using virtual scroll.</p><p>Virtual Scroll will only generate DOM elements which are visible to users. When the user scrolls upwards or backwards, it will automatically add and destroy the elements resulting in creating only DOM elements which are visible to the user. This will improve the websites performance by 80 to 90% for sure.</p><h3>Tutorial</h3><p>Below is the one Realtime example which gives you step by step guidance about how Virtual scroll works and how to implement it in an Angular application.</p><blockquote>ReactJS and VueJS also has node packages to build the infinite scroll.</blockquote><p>We assume that you have already initiated the Angular project.</p><p><strong>Step 1:</strong> Install ngx-virtual-scroller</p><pre>npm install ngx-virtual-scroller</pre><p><strong>Step 2:</strong> Import virtual scroll module into your app module</p><pre>import { VirtualScrollerModule } from ‘ngx-virtual-scroller’;</pre><p><strong>Step 3:</strong> Create the parent component and service component.</p><pre>ng generate component virtual-table<br>ng generate service virtual-list</pre><p><strong>virtual-table.component.ts</strong></p><p>This is parent component in which we are passing list data to child component using @input</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48d4a433bb2b22d87533010c7b97c42e/href">https://medium.com/media/48d4a433bb2b22d87533010c7b97c42e/href</a></iframe><p><strong>virtual-list.service.ts</strong></p><p>virtual-list services will provide data to parent component and parent will pass to the child component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5056d7cc69e4e1732e68bf22060ece4c/href">https://medium.com/media/5056d7cc69e4e1732e68bf22060ece4c/href</a></iframe><p><strong>Step 4:</strong> Create child component call virtual-list as below</p><pre>ng generate component virtual-list</pre><p>The above command will generate the following two files.</p><p><strong>virtual-list.component.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba00036a980a174b6129c76a647a032f/href">https://medium.com/media/ba00036a980a174b6129c76a647a032f/href</a></iframe><p><strong>virtual-list.component.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6f2ebf06730c49fb5cfe5a241614238/href">https://medium.com/media/d6f2ebf06730c49fb5cfe5a241614238/href</a></iframe><p>We can use this child component in any component in which we want to show data in tabular form and all we need to make it work, is provide the data. For example, you can see virtual-table.component.ts where we have passed tableList in items attribute.</p><h3>Conclusion</h3><p>And that’s it! Did this work for you? Please leave any questions and comments below!</p><p>Thank you for reading and If you found this article helpful, clap! 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed2d543be41c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/how-to-use-virtual-scroll-in-angular-to-boost-the-website-performance-ed2d543be41c">How to use Virtual Scroll in Angular to boost the website performance</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concepts to become an advanced React developer]]></title>
            <link>https://medium.com/wineofbits/concepts-to-become-an-advanced-react-developer-684d90c086c2?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/684d90c086c2</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Fri, 26 Oct 2018 15:54:44 GMT</pubDate>
            <atom:updated>2018-11-16T11:46:18.703Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h4>Increase you react level by using these techniques!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNRK_zr3qrTORJXD3pwuZA.png" /><figcaption>React Logo</figcaption></figure><p>We all love ReactJS. It is one of the best and popular way to create SPA(Single Page Application). It offers flexibility and facility. It has great feature to use it to create a single component in the <a href="https://reactjs.org/docs/add-react-to-a-website.html">existing website</a> or use it to create the <a href="https://reactjs.org/docs/create-a-new-react-app.html">whole website</a> from scratch.</p><p>Now ReactJS is a framework used by many other frameworks or toolkits such as <a href="http://nextjs.org/">NextJs</a>, <a href="https://www.gatsbyjs.org/">GatsByJs</a>, Razzle, <a href="https://github.com/jaredpalmer/after.js">AfterJs</a> etc. So becoming a better ReactJS developer will in turn help you to better use these frameworks.</p><h3>Use Fragment instead of div</h3><p>Many times we want to hold multiple components and as render allows only one component to return, we use div tag to contain all of our components. This add an extra HTML element in our document.</p><p>According to the official guide,</p><blockquote>Sometimes we break HTML semantics when we add &lt;div&gt; elements to our JSX to make our React code work, especially when working with lists (&lt;ol&gt;, &lt;ul&gt; and &lt;dl&gt;) and the HTML &lt;table&gt;. In these cases we should rather use <a href="https://reactjs.org/docs/fragments.html">React Fragments</a> to group together multiple elements.</blockquote><pre>import React, { Fragment } from &#39;react&#39;;<br><br>function ListItem({ item }) {<br>  return (<br><strong>    &lt;Fragment&gt;</strong><br>      &lt;dt&gt;{item.term}&lt;/dt&gt;<br>      &lt;dd&gt;{item.description}&lt;/dd&gt;<br><strong>    &lt;/Fragment&gt;</strong><br>  );<br>}<br><br>function Glossary(props) {<br>  return (<br>    &lt;dl&gt;<br>      {props.items.map(item =&gt; (<br>        &lt;ListItem item={item} key={item.id} /&gt;<br>      ))}<br>    &lt;/dl&gt;<br>  );<br>}</pre><p>For more info, see <a href="https://reactjs.org/docs/fragments.html">the Fragments documentation</a>.</p><h3>Use context more</h3><p>As the officials say about it, Context provides a way to pass data through the component tree without having to pass props down manually at every level.</p><p>So if you have multiple components that needs a value then use context. If you have only a single child component that needs this value use <a href="https://reactjs.org/docs/context.html#before-you-use-context">compositions</a>.</p><p>one example to set theme from the official docs,</p><p><strong>theme-context.js</strong></p><pre>export const themes = {<br>  light: {<br>    foreground: &#39;#000000&#39;,<br>    background: &#39;#eeeeee&#39;,<br>  },<br>  dark: {<br>    foreground: &#39;#ffffff&#39;,<br>    background: &#39;#222222&#39;,<br>  },<br>};</pre><pre>export const ThemeContext = React.createContext(<br>  themes.dark // default value<br>);</pre><p><strong>themed-button.js</strong></p><pre>import {ThemeContext} from &#39;./theme-context&#39;;</pre><pre>class ThemedButton extends React.Component {<br>  render() {<br>    let props = this.props;<br><strong>    let theme = this.context;</strong><br>    return (<br>      &lt;button<br>        {...props}<br>        style={{backgroundColor: theme.background}}<br>      /&gt;<br>    );<br>  }<br>}<br><strong>ThemedButton.contextType = ThemeContext;</strong></pre><pre>export default ThemedButton;</pre><p><strong>app.js</strong></p><pre>import {ThemeContext, themes} from &#39;./theme-context&#39;;<br>import ThemedButton from &#39;./themed-button&#39;;</pre><pre>// An intermediate component that uses the ThemedButton<br>function Toolbar(props) {<br>  return (<br>    &lt;ThemedButton onClick={props.changeTheme}&gt;<br>      Change Theme<br>    &lt;/ThemedButton&gt;<br>  );<br>}</pre><pre>class App extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {<br>      theme: themes.light,<br>    };</pre><pre>this.toggleTheme = () =&gt; {<br>      this.setState(state =&gt; ({<br>        theme:<br>          state.theme === themes.dark<br>            ? themes.light<br>            : themes.dark,<br>      }));<br>    };<br>  }</pre><pre>render() {<br>    // The ThemedButton button inside the ThemeProvider<br>    // uses the theme from state while the one outside uses<br>    // the default dark theme<br>    return (<br>      &lt;Page&gt;<br><strong>        &lt;ThemeContext.Provider value={this.state.theme}&gt;</strong><br>          &lt;Toolbar changeTheme={this.toggleTheme} /&gt;<br><strong>        &lt;/ThemeContext.Provider&gt;</strong><br>        &lt;Section&gt;<br>          &lt;ThemedButton /&gt;<br>        &lt;/Section&gt;<br>      &lt;/Page&gt;<br>    );<br>  }<br>}</pre><pre>ReactDOM.render(&lt;App /&gt;, document.root);</pre><h3>Have at least one Error Boundaries</h3><p>React 16 comes with an amazing feature Error Boundaries. As the name suggests, It bounds the error of all the child components. The idea is very simple. Create a React component and use it as parent wherever you want to handle the errors. If there is any error in your child component then your Error Boundary component will be called to handle the error.</p><blockquote>Keep in mind that rendering error are handled using error boundaries. Imperative errors such as in Event handlers should be handled using javascript try/catch blocks.</blockquote><p>Use componentDidCatch() to log error information.</p><pre>class ErrorBoundary extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = { hasError: false };<br>  }</pre><pre>static getDerivedStateFromError(error) {<br>    // Update state so the next render will show the fallback UI.<br>    return { hasError: true };<br>  }</pre><pre>componentDidCatch(error, info) {<br>    // You can also log the error to an error reporting service<br>    logErrorToMyService(error, info);<br>  }</pre><pre>render() {<br>    if (this.state.hasError) {<br>      // You can render any custom fallback UI<br>      return &lt;h1&gt;Something went wrong.&lt;/h1&gt;;<br>    }</pre><pre>return this.props.children; <br>  }<br>}</pre><p>Then you can use it as a regular component:</p><pre>&lt;ErrorBoundary&gt;<br>  &lt;MyWidget /&gt;<br>&lt;/ErrorBoundary&gt;</pre><p>If the ErrorBoundary component has an error in itself then it cannot handle it 😐.</p><p>The feature was there in React 15 named unstable_handleError.This method no longer works, and you will need to change it to componentDidCatch in your code starting from the first 16 beta release.</p><p>For this change, React has provided a <a href="https://github.com/reactjs/react-codemod#error-boundaries">codemod</a> to automatically migrate your code.</p><h3>Use production build in LIVE environment</h3><p>Official site has listed many configurations which can increase your performance. Don’t forget to check them out before deploying to the LIVE environment.</p><p>Check out the guide here, <a href="https://reactjs.org/docs/optimizing-performance.html">reactjs.org/docs/optimizing-performance</a></p><p>It will take merely 10 minutes to configure and will give amazing performance boost to your app.</p><h3>Use Refs to interact with child</h3><p>We can use Refs to trigger animation, text selection or manage the focus.</p><p>For example,</p><p>To set focus in React, we can use <a href="https://reactjs.org/docs/refs-and-the-dom.html">Refs to DOM elements</a>.</p><p>Using this, we first create a ref to an element in the JSX of a component class:</p><pre>class CustomTextInput extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    // Create a ref to store the textInput DOM element<br><strong>    this.textInput = React.createRef();</strong><br>  }<br>  render() {<br>  // Use the `ref` callback to store a reference to the text input DOM<br>  // element in an instance field (for example, this.textInput).<br>    return (<br>      &lt;input<br>        type=&quot;text&quot;<br><strong>        ref={this.textInput}</strong><br>      /&gt;<br>    );<br>  }<br>}</pre><p>Then we can focus it elsewhere in our component when needed:</p><pre>focus() {<br>  // Explicitly focus the text input using the raw DOM API<br>  // Note: we&#39;re accessing &quot;current&quot; to get the DOM node<br><strong>  this.textInput.current.focus();</strong><br>}</pre><p>For more info, see <a href="https://reactjs.org/docs/accessibility.html#programmatically-managing-focus">programmatically-managing-focus</a>.</p><h3>Use code splitting</h3><p>If you’re using CRA(create react app) or NextJs then there will a webpack configuration file already. It will create a single file(bundle) which will contain your whole app. Now if you use third party libraries or your app becomes larger then your bundle file will also be larger. When a user comes to the website then browser will download the whole bundle file and then render the website. This can slow your website drastically so code splitting allows the generated to split and create multiple outputs. So the browser will load the appropriate bundle when it needs it. In turn improving the site load up time.</p><p>We can use <strong>React.lazy</strong> to achieve this,</p><blockquote><em>Official Note:</em><em>React.lazy and Suspense is not yet available for server-side rendering. If you want to do code-splitting in a server rendered app, we still recommend </em><a href="https://github.com/thejameskyle/react-loadable"><em>React Loadable</em></a><em>. It has a nice </em><a href="https://github.com/thejameskyle/react-loadable#------------server-side-rendering"><em>guide for bundle splitting with server-side rendering</em></a><em>.</em></blockquote><p>You can split your code in various ways but a good starting point is based on routes,</p><p>Most people on the web are used to page transitions taking some amount of time to load. You also tend to be re-rendering the entire page at once so your users are unlikely to be interacting with other elements on the page at the same time.</p><p>Here’s an example of how to setup route-based code splitting into your app using libraries like <a href="https://reacttraining.com/react-router/">React Router</a> with React.lazy.</p><pre>import { BrowserRouter as Router, Route, Switch } from &#39;react-router-dom&#39;;<br>import React, { Suspense, lazy } from &#39;react&#39;;</pre><pre>const Home = lazy(() =&gt; import(&#39;./routes/Home&#39;));<br>const About = lazy(() =&gt; import(&#39;./routes/About&#39;));</pre><pre>const App = () =&gt; (<br>  &lt;Router&gt;<br>    &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>      &lt;Switch&gt;<br>        &lt;Route exact path=&quot;/&quot; component={Home}/&gt;<br>        &lt;Route path=&quot;/about&quot; component={About}/&gt;<br>      &lt;/Switch&gt;<br>    &lt;/Suspense&gt;<br>  &lt;/Router&gt;<br>);</pre><p><strong>Suspense</strong> is nothing but a fallback mechanism. if the required bundle is not loaded yet then it will be shown. You can add a your spinner here to show loading sign to your users.</p><blockquote>You can even use ErrorBoundary as parent to Suspense to handle other error such as network error!</blockquote><p>React.lazy currently only supports default exports. So if you want to use it with named exports, check out <a href="https://reactjs.org/docs/code-splitting.html#named-exports">named-exports</a>.</p><h3>Static Type Checking</h3><p>Javascript is not typed language and many of the problems arise due to wrong types.</p><p>we can use various type checkers available in the market But one famous and beginner friendly tool is <a href="https://flow.org/">Flow</a>. It is developed at Facebook and is often used with React. It lets you annotate the variables, functions, and React components with a special type syntax, and catch mistakes early. You can read an <a href="https://flow.org/en/docs/getting-started/">introduction to Flow</a> to learn its basics. step by step instructions are given in this <a href="https://reactjs.org/docs/static-type-checking.html#flow">official react guide</a>.</p><h4>Bonus tip</h4><p>Ensure that your web application can be fully operated with the keyboard only,</p><ul><li><a href="http://webaim.org/techniques/keyboard/">WebAIM talks about keyboard accessibility</a></li></ul><p>Thank you for reading!</p><p>Please leave comments if you have any suggestion/s or would like to add a point/s or if you noticed any mistake/typos!</p><p>P.S. If you found this article helpful, clap! 👏👏👏 [feels rewarding and gives the motivation to continue my writing].</p><ul><li><a href="https://medium.com/wineofbits/curated-list-of-really-useful-react-posts-to-improve-your-react-app-10x-24d5463fe6e1">Curated List of REALLY useful react posts to improve your react app 10x</a></li><li><a href="https://medium.com/wineofbits/use-redux-in-your-react-app-in-just-10-minutes-8da6e9f043c5">Use Redux in your React app in just 10 minutes</a></li></ul><p>For more information,</p><p>check out the Advanced guide on official guide, <a href="https://reactjs.org/docs/getting-started.html">https://reactjs.org/docs/getting-started.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=684d90c086c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/concepts-to-become-an-advanced-react-developer-684d90c086c2">Concepts to become an advanced React developer</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My first Ruby on Rails + React App in just 15 minutes]]></title>
            <link>https://medium.com/wineofbits/my-first-ruby-on-rails-react-app-in-just-15-minutes-51d73f0de3c6?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/51d73f0de3c6</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Sat, 29 Sep 2018 12:01:02 GMT</pubDate>
            <atom:updated>2018-09-29T12:01:02.262Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h4>How to create Ruby on Rails application with React</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*PFEk9y9K_k5Ql58pC567-A.png" /><figcaption>React + Ruby on Rails</figcaption></figure><p>Today I learned ruby and had some time to experiment with Ruby on Rails. As I am already familiar with React, I decided to create a simple CRUD application with RoR and React.</p><p>So if you want to learn how to use React with RoR then follow along. if you just want the code directly then checkout this for my <a href="https://github.com/drex44/react-ror-crud-app">github repo</a>.</p><h3>Tutorial</h3><h4>Step-1: Work Environment</h4><p>Let’s Setup the work environment. I assume you have already installed ruby. so let’s install other dependencies.</p><p>if you do not have sqlite3 already installed then use below commands or find one on official website,</p><pre>brew install sqlite3<br>yum install sqlite-devel<br>apt-get install libsqlite3-dev</pre><p>Install rails</p><pre>gem install rails</pre><p>We are going to start by creating a new Rails app, running the following command:</p><pre>rails new react-ror-app</pre><p>Next head to Gemfile and add gem &#39;react-rails&#39;, next run</p><pre>bundle install</pre><p>then</p><pre>rails g react:install</pre><p>React:install generator that we are using here automatically adds React JS library to your asset pipeline.</p><h4>Step-2: Creating API in RoR</h4><p>It’s time to create the model and controller in RoR to create a CRUD Api.</p><p><strong>Model</strong></p><p>Run below command to create a new model named Article,</p><pre>rails g model Article title:string text:text</pre><p>Migrate and seed your database,</p><pre>rake db:migrate &amp;&amp; rake db:seed</pre><p><strong>Controllers</strong></p><p>We need to make only one adjustment to our Application Controller. So inside app/controllers/application_controller.rb paste the following line of code,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f8607c1a66719303d1de092fa5d0485/href">https://medium.com/media/4f8607c1a66719303d1de092fa5d0485/href</a></iframe><p>Our application is API-based and so controllers folders structure require us following namespace convention with API version specification, like so: app/controllers/api/v1. Versioning the API means that changes can be made to it in future without damaging the original version.</p><p>So let’s create these two descending folders (api and v1) inside app/controllers, and a new file inside them calledarticles_controller.rb</p><p>we will define CRUD actions in our Article’s controller,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e30a33bd564dffb2fd888e7fc648d2b4/href">https://medium.com/media/e30a33bd564dffb2fd888e7fc648d2b4/href</a></iframe><h4>Connecting the Route with our Article’s controller</h4><p>Let’s navigate config/routes.rb and set up all the necessary routes for CRUD:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c737a60d35e97048696fd6936aa4a2e8/href">https://medium.com/media/c737a60d35e97048696fd6936aa4a2e8/href</a></iframe><blockquote>if you go to <a href="http://localhost:3000/api/v1/articles.json">http://localhost:3000/api/v1/articles.json</a> in your browser, you will see the JSON containing our article/s.</blockquote><p>Now create one more controller called Home in a corresponding new file app/controllers/home_controller.rb that will be responsible for just one index page, this will be responsible for our React integration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f7266c363d4b9b20247e721723e2307/href">https://medium.com/media/2f7266c363d4b9b20247e721723e2307/href</a></iframe><p>Now return to the config/routes.rb and add our Home index page to be the root of our App:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47a7953bd4b6b5da0d1c9f4499daaf32/href">https://medium.com/media/47a7953bd4b6b5da0d1c9f4499daaf32/href</a></iframe><p>Now all our index page need is a corresponding view. Create a new ‘home’ folder inside app/views and add index.html.erb file to it:</p><pre>app/views/home/index.html.erb</pre><p>This file will only contain one line that takes advantage of <strong>react_component </strong>view helper that comes with <strong>‘react-rails’</strong> gem. It’s not going to work right now, but it all will make sense in a moment.</p><pre>&lt;%= react_component &#39;Main&#39; %&gt;</pre><h4>Step-3: Creating our React Components</h4><p>we will use container and component structure for our component.</p><blockquote>container/smart component: contains all the login and state</blockquote><blockquote>component/dumb component: contains only representation.</blockquote><p>Create a file named app/assets/javascripts/components/_main.js.jsx</p><p>We are going to follow the usual syntax for creating a stateless/presentational/dumb React Component that we will call <strong>Main</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8580ddf4049eab699232a23f4beeaf2/href">https://medium.com/media/f8580ddf4049eab699232a23f4beeaf2/href</a></iframe><p>If you go to <a href="http://localhost:3000/">http://localhost:3000,</a> you will see our Main component on the home page. Remember our index.html.erb?</p><blockquote>we imported Main react component in our index.html.erb</blockquote><p><strong>Let’s create our Article component</strong></p><p>Create a file named app/assets/javascripts/components/_article.js.jsx</p><p>This will be a [dumb] component that we will use to display articles.</p><p>here, we use editable state property to show and hide the input fields when edit button is clicked. as this component is dumb, it won’t perform the actual update or delete but it will call the methods passed through props.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1eb3036e69f67851435456b331aaa8c0/href">https://medium.com/media/1eb3036e69f67851435456b331aaa8c0/href</a></iframe><p>Now let’s create a higher order component or parent component that will take all articles via props and display all the articles using Article created above.</p><p>Create a file named app/assets/javascripts/components/_all_articles.js.jsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1678ca3ceecc9f14d15b71a5273d4021/href">https://medium.com/media/1678ca3ceecc9f14d15b71a5273d4021/href</a></iframe><p>This two components will take care of the Read, Update and Delete but what about Create?</p><p>So let’s create a new component which will contain a form with two input fields. title and text.</p><p>Create a file named app/assets/javascripts/components/_new_article.js.jsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f58825ef4590d233209c5b82fe937bee/href">https://medium.com/media/f58825ef4590d233209c5b82fe937bee/href</a></iframe><p>Now it’s time to use above three components into our <strong>container</strong>(_articles_container.js.jsx). this is the last component and we will add this into main and magic will happen! our whole app will come alive and will have all CRUD operations in it.</p><p>Create a file named app/assets/javascripts/components/_articles_container.js.jsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75aa2b2c570cdd41bf4f97d08b274f2c/href">https://medium.com/media/75aa2b2c570cdd41bf4f97d08b274f2c/href</a></iframe><p>Just bear with me for last time, we have use this container in our main component to load it into the website.</p><p>Add this component in ourapp/assets/javascripts/components/_main.js.jsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c58d3acd87e6aa9f55dc3a7dc0a34284/href">https://medium.com/media/c58d3acd87e6aa9f55dc3a7dc0a34284/href</a></iframe><p>That’s it! Now You can perform all CRUD actions with your articles. There was a lot of code in this blog post, so if you’d like to see the full code of the finished app, please checkout this github repo:</p><p><a href="https://github.com/drex44/react-ror-crud-app">https://github.com/drex44/react-ror-crud-app</a></p><p>Thank you for reading! please leave comments if you have any suggestions or if you noticed any mistakes/typos!</p><p>Lastly, If you found this article helpful, clap! 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51d73f0de3c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/my-first-ruby-on-rails-react-app-in-just-15-minutes-51d73f0de3c6">My first Ruby on Rails + React App in just 15 minutes</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host your dynamic website without spending a penny!]]></title>
            <link>https://medium.com/wineofbits/host-your-dynamic-website-without-spending-a-penny-d1ba91501a62?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/d1ba91501a62</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Tue, 11 Sep 2018 12:01:02 GMT</pubDate>
            <atom:updated>2018-09-12T05:34:37.943Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>Create a dynamic app using NextJs and Prismic CMS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhHk66IJIFl5CQm25TE5VQ.png" /><figcaption>Prismic + NextJs</figcaption></figure><blockquote>This post contains NextJs and Prismic app tutorial but the basic idea can be applied with any Static website platform.</blockquote><p>Have you ever wondered about having a website whose content can be changed without going through the DB queries or without asking a developer? duh, we have wordpress, Drupal etc.</p><p>Okay. But what if you don’t have a server? what if you want to scale your website for a million users? Increasing the server horizontally or vertically is a one way to do it but you have to spend money for it.</p><p>So if you are either the business person, a startup founder, an NGO founder or a small businessman, you can get the idea about the process and ask your developer to create a similar website. this will help you a lot later on as you won’t have to pay or ask somebody else to make changes in the content.</p><h4>What this post covers?</h4><ul><li>It gives you an idea of how one can create such business user friendly websites. this is a very pocket-friendly and scalable way to create a website which can serve a million users.</li><li>A tutorial on creating one such application (shows the latest notices or news from the college or schools).</li></ul><h4>What’s the alternative?</h4><p>You can use Adobe AEM, Microsoft SharePoint, Drupal etc but you need a separate server for those and extra bucks. Moreover creating websites in such tools require experienced developers which again increases the cost.</p><h4>Overall Idea</h4><p>Create an SPA or a similar static website and fetch the content from a CMS (content management system).</p><p>we will be using surge to host our website free (Custom domain, Unlimited publishing, and Basic SSL) and prismic.io(CMS) to deliver dynamic content to our website. we will use 1 user basic plan which is free. you can use contentful, storyblok, ButterCMS etc. So here the only charge you have to pay is for CMS which is very low compared to a tradition hosting servers.</p><h3>Tutorial</h3><p>If you want to know how to create and host such an application, follow along. Let the hacking begin and May the force be with you.</p><p>We will use NextJs(Basically a React App). I had heard about it a lot and wanted to know what’s the buzz about. It’s really easy and found it very useful. if you do not have much knowledge about NextJs, do not worry. I will explain wherever it is necessary.</p><h4>Step-1</h4><p>Run below commands.</p><pre>mkdir bulletin<br>cd bulletin<br>npm init -y<br>npm install --save react react-dom next<br>mkdir pages</pre><p>Install prismic.io dependecies. we will use it later.</p><pre>npm install prismic-javascript prismic-reactjs --save</pre><p>Then open the “package.json” in the bulletin directory and add the following NPM script.</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;next&quot;,<br>    &quot;build&quot;: &quot;next build&quot;,<br>    &quot;export&quot;: &quot;next export&quot;,<br>    &quot;start&quot;: &quot;next start&quot;<br>  }<br>}</pre><p>Now everything is ready. Run the following command to start the dev server:</p><pre>npm run dev</pre><p>Then open <a href="http://localhost:3000/">http://localhost:3000</a> from your favourite browser. you will see 404 error message.</p><h4>Step-2</h4><p>Inside pages create two files.</p><blockquote>Pages directory is the special a directory in NextJs. whichever files we keep here, NextJs will assign it a route just like Php. only thing necessary in file is we have to export the component as default which we want as entry point to out route.</blockquote><ul><li>index.js: (corresponds to / route)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f96751bb904c37317fa75f3355483db4/href">https://medium.com/media/f96751bb904c37317fa75f3355483db4/href</a></iframe><p>It use News and Layout components. create a new components directory in root of the app. create two files News.js and Layout.js inside components.</p><p>In Layout.js and Footer.js, we are using Link component from NextJs to wrap our internal links.</p><p>In News.js, we are using prismic-reactjs lib to render the content coming from Prismic.io.</p><ul><li>News.js</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/204f5a34795502cad1d1e9f07230a455/href">https://medium.com/media/204f5a34795502cad1d1e9f07230a455/href</a></iframe><ul><li>Layout.js</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/361534f0c553adb256730c0304aaee2b/href">https://medium.com/media/361534f0c553adb256730c0304aaee2b/href</a></iframe><p>Sorry for the modular code 😐 but Layout uses a component named Footer.js so create one more file inside components named Footer.js.</p><ul><li>Footer.js</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf0398474f6d70eee03c1cf4559ac512/href">https://medium.com/media/bf0398474f6d70eee03c1cf4559ac512/href</a></iframe><ul><li>page.js (corresponds to /page)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73236c3e085ae06eed7b7f54fae11e37/href">https://medium.com/media/73236c3e085ae06eed7b7f54fae11e37/href</a></iframe><h4>Step-3</h4><p>It’s time to create some data for our frontend. Go to the prismic and create a new repository. create a two new custom types. custom types are a template which we will fill whenever we need new data.</p><p>Create a repeatable type named “Page”. In the json editor paste below json and click on save.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ac0562acf532f5bf5030bc571daa0ef/href">https://medium.com/media/6ac0562acf532f5bf5030bc571daa0ef/href</a></iframe><p>Create another repeatable type named “news”. In the json editor paste below json and click on save.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab8eb968d6466ab7497c04fb64668c0f/href">https://medium.com/media/ab8eb968d6466ab7497c04fb64668c0f/href</a></iframe><p>Go to the “content” tab and add new document. select the “news” type and create your first notice.</p><p>Similarly create three more documents of type “Page”.</p><p>While creating these pages, give these UIDs: about, privacy, and terms. we are using these IDs to fetch the pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2n1KXCQkLU4D1OqURf0PsA.png" /><figcaption>All documents in Prismic.io</figcaption></figure><h4>Step-4</h4><p>Time to fetch the data into our frontend.</p><p>In NextJs, we have an amazing function named getInitialProps. NextJs runs this function before rendering the component. here we will fetch the data from Prismic.io.</p><blockquote>Remember, getInitialProps can be used only with exported default React component. that is why we fetch the news in index.js and pass it to News component.</blockquote><p>Modify the index.js and page.js as below.</p><ul><li>index.js</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/316cb9a458eba4d2ed6347a3fac09073/href">https://medium.com/media/316cb9a458eba4d2ed6347a3fac09073/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0796ab78245336907019dcdde12009cb/href">https://medium.com/media/0796ab78245336907019dcdde12009cb/href</a></iframe><p>we have to define the endpoint to our Prismic.io data repository. we have used a separate configuration file to keep Prismic related configurations.</p><p>So in the root of the app create a new file named “prismic-configuration.js”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5339926304d815ba4da5710264eee2d/href">https://medium.com/media/d5339926304d815ba4da5710264eee2d/href</a></iframe><p>we have to create a NextJs specific file to support of client side routes (last file).</p><p>create a new file next.config.js.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0d1606a32d25e829f6ca2a835ff5a6b/href">https://medium.com/media/b0d1606a32d25e829f6ca2a835ff5a6b/href</a></iframe><h4>Step-5</h4><p>It’s time to launch the app. run below command to run the app locally.</p><pre>npm run dev</pre><p>Build the app to host it live.</p><pre>npm run build<br>npm run export</pre><p>This will output the static site inside out directory.</p><p>Now install surge and host it live. the url will be shown on the terminal.</p><pre>npm install --global surge <br>cd out<br>surge</pre><p>The whole project code is available on github and is also live on surge.</p><p>github: <a href="https://github.com/drex44/bulletin">drex44/bulletin</a></p><p>surge: <a href="http://bulletin-tutorial.surge.sh/">bulletin-tutorial.surge.sh</a></p><p><strong>Conclusion</strong></p><p>And that’s it! Did this work for you? Please leave any questions and comments below!</p><p>Thank you for reading!</p><p>If you found this article helpful, clap! 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1ba91501a62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/host-your-dynamic-website-without-spending-a-penny-d1ba91501a62">Host your dynamic website without spending a penny!</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Redux in your React app in just 10 minutes]]></title>
            <link>https://medium.com/wineofbits/use-redux-in-your-react-app-in-just-10-minutes-8da6e9f043c5?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/8da6e9f043c5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 12:16:01 GMT</pubDate>
            <atom:updated>2018-09-04T12:16:01.010Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*meCFnZ5MK_7Fu1ogYfBvNQ.png" /><figcaption>React + Redux</figcaption></figure><p>You have decided to use Redux as your state management library, now you actually have done the hard part. deciding which library to use. everything else is very easy and fast. follow along to create a todo app with redux in just 5 minutes.</p><h4>The idea behind Redux</h4><p>You have mainly three components store, reducer, and actions.</p><p>As Redux says,</p><p>A <strong>Store</strong> holds the whole state [tree] of your application. The only way to change the state inside it is to dispatch an action on it.</p><p><strong>Actions</strong> are payloads of information that send data from your application to your store. They are the <em>only</em> source of information for the store.</p><p>we will define two actions, createItem and deleteItem.</p><p><strong>Reducers</strong> specify how the application’s state changes in response to <strong>actions</strong> sent to the store. Remember that actions only describe <em>what happened</em>, but don’t describe how the application’s state changes.</p><p>we will create one reducer just like a table in sql db. there can be may according to your application.</p><h3>Tutorial</h3><h4>Step-1</h4><p>Create a new react app using CRA(create-react-app).</p><pre>create-react-app todo-app</pre><h4>Step-2</h4><p>Install dependencies</p><pre>npm install <em>lodash @material-ui/core @material-ui/icons react-redux redux redux-logger</em></pre><h4>Step-3</h4><p>If you want to learn an efficient way to store your files, use ducks file structure. But for simplicity, we will be using simple file structure.</p><p>Create a new folder inside src named “<strong>modules</strong>”</p><p>create three files inside the folder: <strong>action.js, reducer.js, store.js</strong></p><p><strong>actions</strong> are simple objects with one mandatory property <strong>type. </strong>you dispatch actions from your component to send data to the state store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/696aa23a76f5ae1c622e1324c305c432/href">https://medium.com/media/696aa23a76f5ae1c622e1324c305c432/href</a></iframe><blockquote>Ideally, you should create another file for your action types.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a459a481a152a23f4f25bbc811ca543/href">https://medium.com/media/4a459a481a152a23f4f25bbc811ca543/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30aa7f39840b5dfccc2eba5fe314865a/href">https://medium.com/media/30aa7f39840b5dfccc2eba5fe314865a/href</a></iframe><h4>Step-4</h4><p>create a new <strong>todo.js</strong> in a new folder inside src named <strong>“pages”</strong>. this will contain our todo list component. this example is focused on Redux so we won’t try to create component/containers. we will have our entire app in this file only.</p><p>Create the UI with a form and a list to show the tasks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2857a5fb3661471ada6c72dab865184/href">https://medium.com/media/f2857a5fb3661471ada6c72dab865184/href</a></iframe><h4>Step-5</h4><p>It’s time to connect our todo component with the redux store.</p><p>Open your App.js and add redux provider so all of the children can access the store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/961d3774afe82203cfe590f36b5d07f4/href">https://medium.com/media/961d3774afe82203cfe590f36b5d07f4/href</a></iframe><p>Inside your todo.js, connect it with the store using connect component from react-redux. add these at the end of the file in todo.js.</p><p>Now the items from store will be available in component’s props. Also the other two functions(actions) will be available in props.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ee2d0f42a3f1cab2c00fe596a85b0c9/href">https://medium.com/media/7ee2d0f42a3f1cab2c00fe596a85b0c9/href</a></iframe><p>Lastly, call createItem and deleteItem inside of handleSubmit and handleDelete respectively.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1c1f6144031c561c1ff6f199a4ff7ca/href">https://medium.com/media/a1c1f6144031c561c1ff6f199a4ff7ca/href</a></iframe><p>If you want the whole app code then it is available at this <a href="https://github.com/drex44/todo-redux-app">github repository</a>.</p><p><strong>Conclusion</strong></p><p>And that’s it! Did this work for you? Please leave any questions and comments below!</p><p>Thank you for reading!</p><p>If you found this article helpful, clap! 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8da6e9f043c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/use-redux-in-your-react-app-in-just-10-minutes-8da6e9f043c5">Use Redux in your React app in just 10 minutes</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Must use tools for react developers]]></title>
            <link>https://medium.com/wineofbits/must-use-tools-for-react-developers-f2191e6a694?source=rss----48af64ece580---4</link>
            <guid isPermaLink="false">https://medium.com/p/f2191e6a694</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Dhanraj Acharya]]></dc:creator>
            <pubDate>Wed, 29 Aug 2018 12:08:37 GMT</pubDate>
            <atom:updated>2018-08-29T12:08:36.905Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>This is a curated list of tools which will help you in your development process. I wish I knew these tools before and it would have changed my process completely.</p><blockquote>beware, this is a no image article!</blockquote><h4>Surge</h4><p>Free static site hosting. Simple, single-command web publishing. Publish HTML, CSS, and JS for free, without leaving the command line.</p><p>So any static website can be hosted here for FREE OF COST FOREVER (That is until they don’t but they will).</p><h4>React Router v4</h4><p>If you want to know how to add links and handle navigation then this is your answer. In SPA, navigation is handled via changing the history object of the browser. Such kind of routing library typically makes this process very easy and straight forward.</p><h4>React Snapshot</h4><p>While developing Single page applications, you may come across server side rendering and for beginners, it’s a lot of setup. this little guy here, converts your website and provides server side rendering.</p><blockquote>Server Side Rendering: Your SPA are rendered on the client. everything is just one single page changing routes. In many cases, you may need to use SSR. one such case is user bookmarking a link in your website and when he visits it, it doesn’t exists! error 404! what!</blockquote><p>Follow this amazing article to know more about react snapshot and how to use it: <a href="https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319">medium.com/superhighfives/an-almost-static-stack</a></p><h4>React helmet</h4><p>Want to control the tags in your head html dynamically? worry not! React Helmet is one such pretty damn famouse library just for that.</p><h4>React Redux</h4><p>Once you start to create a big application in react, you will come across this nightmare of handling the state and props of react components. you will have difficulty keeping it consistent across the components and may face many problems. state management libraries are that super hero which solves this god damn problem. now there are many lirbaries out there, you can use anyone you like. but if you can’t decide which one to pick, start with redux.</p><h4>General purpose library</h4><p><a href="https://lodash.com/">lodash</a>: Utility functions for almost everything</p><p>For more information,</p><p>This is a similar posts but with a list of amazing articles which help you boost your react knowledge!</p><p><a href="https://medium.com/wineofbits/curated-list-of-really-useful-react-posts-to-improve-your-react-app-10x-24d5463fe6e1">medium.com/wineofbits/curated-list-of-really-useful-react-posts-to-improve-your-react-app-10x</a></p><p>Thank you for reading!</p><p>If you have any suggestions and additions to the list comment below.</p><p>One more thing, if found this article helpful, clap! 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2191e6a694" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wineofbits/must-use-tools-for-react-developers-f2191e6a694">Must use tools for react developers</a> was originally published in <a href="https://medium.com/wineofbits">wineofbits</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>