Saransh Kataria

CSS :has a parent selector now

CSS :has a parent selector now

  • November 12, 2022

CSS now includes a :has selector that allows us to apply styles on the basis of what is happening inside an element. Often referred to as a parent seletor, the :has() function allows us to achieve this and more. Let us take a look at this relative selector. It only...

Using Font Awesome with React

Using Font Awesome with React

  • October 22, 2022

Font Awesome is a great resource to use various types of icons in your project including well-known social media icons and a lot more. It can be used with any front-end library. In this post, we are going to be using Font Awesome with React. Set up The first step...

How to write comments in React (JSX)?

How to write comments in React (JSX)?

  • October 15, 2022

I was recently trying to comment out some logic inside my JSX to add context about what a potentially complex logic. I then realized that comments in JSX are weird. So, how to write comments in React (JSX)? You cannot use HTML comments because they are parsed as DOM nodes:...

How to write more readable JavaScript conditionals

How to write more readable JavaScript conditionals

  • October 4, 2022

One of the practices of clean code is to make it more readable. And a fairly common use case in code bases is conditionals. I recently came across a way of writing more readable JavaScript conditionals and thought of sharing it with everyone. Consider the following conditional: The mind takes...

Deep copying in JavaScript using structuredClone

Deep copying in JavaScript using structuredClone

  • August 23, 2022

For as long as anyone can remember, deep copying in JavaScript was not a built-in feature and we had to resort to libraries or workarounds to create a deep copy of a JavaScript value. That has changed now. The platform now offers a built-in function that does deep copying for...