Escaping if-else maze in JavaScript
Sabesan Sathananthan
by Sabesan Sathananthan
1M ago
Simplifying JavaScript Logic source: link Typically, many developers easily fall into the if-else trap, not because of the complexity of other solutions, but because it follows the natural language pattern. This is my 45th Medium article. In below, I added the example of multiple if-else spaghetti code. const setColor = (color) => { let colorHexCode = ''; if (color === 'blue') { colorHexCode = '#4169E1'; } else if (color === 'green') { colorHexCode = '#98FF98'; } else if (color === 'butter') { colorHexCode = '#FFE4C9'; } else if (color === 'pink ..read more
Visit website
What Are Microservices?
Sabesan Sathananthan
by Sabesan Sathananthan
1y ago
Microservices are a type of software architecture that is gaining popularity. Photo by Pavel Danilyuk What does the term “microservices” mean exactly? What sort of architecture falls within the microservices? Despite the abundance of materials online, none of them are easy for beginners to understand. In my opinion, this concept is actually rather straightforward and is easily explainable. Nowadays, developers need to do changes to an application and need to deploy it as soon as possible without redeploying the whole application. This problem led to the microservices development paradigm ..read more
Visit website
The Medium RSS Feed’s Missing Part
Sabesan Sathananthan
by Sabesan Sathananthan
2y ago
retrieves the stats (clapCount, voterCount, responseCount, and readingTime) of Medium posts Photo by Ryoji Iwata on Unsplash In this article, I will explain how to retrieve the stats ( claps count, voter count, response count, and reading time) of Medium feed posts using a REST API, the lack of this feature in the Medium RSS feed is what motivated me to create this advanced Medium API. This is my 41st Medium article. Initial Intuition I wanted to obtain the stats ( claps count, voter count, response count, and reading time) of my Medium posts while working on my personal website ..read more
Visit website
Why and How to Use Absolute Imports in React
Sabesan Sathananthan
by Sabesan Sathananthan
2y ago
Front End An easy way to maintain clean code in React Photo by Ketut Subiyanto from Pexels Using absolute imports to better organize your React project is a great way. Relative imports are hard to follow and break during refactoring. Absolute imports manage your project easier as it grows. Forget long relative imports after this article. This is my 40th Medium article. The Problem What if your project’s folder structure is complex, and you need to go up in it? Inside of your components, you have imports that look like the below example with relative imports. import {MyComp ..read more
Visit website
Using Absolute Imports in ReactJs
Sabesan Sathananthan
by Sabesan Sathananthan
2y ago
FRONT END An easy way to maintain a clean code based in React Photo by Ketut Subiyanto from Pexels Using absolute imports to better organize your React project is a great way. Relative imports is hard to follow, and that breaks during refactoring. Absolute imports manage your project easier as it grows. Forget long relative imports after this article. This is my 40th Medium article. The Problem What if your project’s folder structure is complex, and you need to go up in it? Inside of your components, you have imports that look like the below example with relative imports ..read more
Visit website
How to mock network request in Jest
Sabesan Sathananthan
by Sabesan Sathananthan
2y ago
TESTING Mocking network requests even easier Photo by Taylor Vick on Unsplash Nowadays, it is necessary to modify an older library to TS and perform unit testing. If the library is modified to TS, there is still a little bit better. Unit testing is purely a current study and sold now. For beginners to learn the Jest framework, I think the more troublesome thing in unit testing is to test network requests. So record some of the ways that Mock dropped Axios to initiate network requests. This is my 39th Medium article. Introduction The examples mentioned in the article are all in t ..read more
Visit website
How To Reuse React Components
Sabesan Sathananthan
by Sabesan Sathananthan
3y ago
Mixins, HOC, render props, and Hooks are four ways to reuse components Photo by Vlada Karpovich from Pexels Now frontend engineering is more and more important. Although Ctrl+C and Ctrl+V can also be used to complete requirements, once they are modified, it becomes a huge task. Therefore, copying of code is reduced, and the packaging and reuse capabilities are increased to achieve maintainability and reversibility. The code used becomes particularly important. In React, components are the main unit of code reuse. The combination-based component reuse mechanism is quite elegant, but for mo ..read more
Visit website
Deep Insights Into JavaScript’s Fetch API
Sabesan Sathananthan
by Sabesan Sathananthan
3y ago
A deeper look at fetch Photo by Rob Fuller on Unsplash Requesting resources from an API is a popular and nearly crucial feature required for building modern applications. Whether you have created your own API or you are implementing a third-party API, you need a way to create your requests without slowing down your application. fetch() is an upgraded version of XMLHttpRequest, used to make HTTP requests in JavaScript scripts. The main difference between Fetch and XMLHttpRequest is that the Fetch API uses Promises, hence avoiding callback hell. The fetch API is natively supported by a ..read more
Visit website
Easy to Learn React Hooks
Sabesan Sathananthan
by Sabesan Sathananthan
3y ago
FRONT END Take useEffect() as an example Photo by Grant Durr on Unsplash I already wrote about React best practices. I have mentioned that React hooks write stateful functional components. Nowadays, Most of the React frameworks such as react-i18next, Material-UI, and etc are encouraged to use React hooks. However, recently I have come to realize that React hooks are very useful. React hooks are introduced after the React v16.08. Here I am going to describe React hooks very simply and easily. This is my 34th Medium article. Two sets of React API In the past, there was only o ..read more
Visit website
Embed your GitHub project on your React website
Sabesan Sathananthan
by Sabesan Sathananthan
3y ago
FRONT END Embed GitHub repo on your Website using Material-UI gives better UI Photo by Markus Winkler on Unsplash They say imitation is a form of flattery but honey, it is time to get your own ideas. I thought to embed my GitHub projects on my website like pinned repositories in GitHub. First I faced a problem that how could I get the programming language colors as shown in GitHub. Then I found that was defined in GitHub linguist. But linguist file defined in YAML Therefore, I fetched that data and convert it to JSON. Therefore I created an API to fetch the linguist details. But ..read more
Visit website

Follow Sabesan Sathananthan on FeedSpot

Continue with Google
Continue with Apple
OR