What is Prop Drilling and How to Avoid It

Farhan Muhamed
Updated on 29-Nov-2024 12:07:47

292 Views

Prop Drilling is a common mistake beginners make while building React apps. It can cause reduced code readability and even performance issues for the app. In this article, I will explain what are props, prop drilling, and how to avoid prop drilling using context APIs. Table of Content What are Props? Prop Drilling Why to Avoid Prop Drilling? Fix Prop Drilling With Context API Prerequisites Good knowledge of React, useState Hook, and useContext Hook. ... Read More

Create Dynamic Variable Names Inside a JavaScript Loop

Shubham Vora
Updated on 29-Nov-2024 11:25:08

16K+ Views

To create dynamic variable names inside a JavaScript loop, means it is not hardcoded already, and we can create it according to our needs from some other string values. For achieving this, we will be understanding four different approaches. In this article our task is to create dynamic variable names inside a JavaScript loop. Approaches to Create Dynamic Variable Names Here is a list of approaches to create dynamic variable names inside a JavaScript loop which we will be discussing in this article with stepwise explanation and complete example codes. Using Array ... Read More

JavaScript Program to Find Area of a Circle

AmitDiwan
Updated on 28-Nov-2024 17:10:17

20K+ Views

To find area of a circle using javascript, we will be using simple formulae of calculating the area of circle. The formula used is: Area = π × r² where r is the radius and π is a constant value pi. In this article, we are having radius of the circle and our task is to find the area of the circle using JavaScript. Example let radius = 10 and π(pi) = 3.1415926535 Area = π × r² Area= 3.1415926535 * 10 * 10 Area= 314.15926535 Steps to Find Area of Circle ... Read More

Display Unordered List in Two Columns

Eesha Gandhi
Updated on 28-Nov-2024 14:07:57

6K+ Views

In HTML, unordered lists are collections of items that do not have to be in any particular order. To list these items, we frequently use simple bullet points and that is why they are often known as bulleted lists. An unordered list begins with the tag and closes with a tag. The list items begin with the tag and end with tag. The tag, which stands for unordered list, is the li tag's parent. This means that the tag is the tag's child. Following is the syntax List of Items There can be ... Read More

Java String Comparison Sample Code Examples

Ramu Prasad
Updated on 28-Nov-2024 13:01:10

237 Views

In this article, we will learn how to compare strings in Java using the compareTo() method and the == operator. These methods help in checking string values and references. comapareTo() method The compareTo() method compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string. The == operator: You can compare two strings using the == operator. However, it compares references to the given variables, not values. ... Read More

Disable Apps Running in the Background

sakshi sharma
Updated on 28-Nov-2024 12:08:19

106 Views

Do you feel like your CPU usage is high on your PC and that is interfering with its performance? Now, you open up the task manager only to find out a number of applications running. But to your surprise, you are not actively using any of them. The applications performing operations in the background on your computer are often called background applications. You might be looking for an easy way out of this situation and therefore landed here. So, we are glad to tell you that we not only have an ... Read More

Return All Boundary Elements of a Matrix in C++

AYUSH MISHRA
Updated on 28-Nov-2024 11:49:26

7K+ Views

boundary elements of a matrix The boundary elements of a matrix are those elements that lie along its edges. A matrix is a two-dimensional array that can be of any given size. The boundary elements are those present on the edges of the matrix. Problem Description We are given a matrix of size m × n. We need to find the boundary elements of the matrix. Boundary elements are the elements present on the top and bottom rows and the first and last columns of the matrix. Below are examples to understand the boundary traversal of a matrix: ... Read More

Return Quadrants for Given Coordinates in C++

AYUSH MISHRA
Updated on 28-Nov-2024 11:31:47

7K+ Views

Cartesian-coordinate System and Quadrants The cartesian-coordinate system is divided into four Quadrants: Quadrant I, Quadrant II, Quadrant III, and Quadrant IV. In this article, we are going to learn how we can determine the quadrant in which given points i.e., x and y, lie. Problem Description We are given the position of a point (x, y), and we have to determine in which quadrant this point lies. Example Input: (-3, 2) Output: Quadrant II Input: (2, 5) Output: Quadrant I Input: (2, -4) Output: Quadrant IV Input: (-6, -3) Output: Quadrant III Using Conditional Quadrant Identification Approach ... Read More

Parallelogram Star Pattern Using C++

AYUSH MISHRA
Updated on 28-Nov-2024 11:14:45

10K+ Views

When we start learning to code, practicing star patterns is one of the best ways to improve logic building. One of the engaging patterns is the parallelogram pattern. In this article, we are going to learn how to print a Parallelogram Star Pattern using C++. What is Parallelogram Pattern? A parallelogram pattern is a geometrical arrangement of stars in a parallelogram shape. The stars are printed in such a manner that if we draw a closed figure on the boundary of the printed pattern, it will resemble a parallelogram. Each row is shifted with space, which creates a diagonal ... Read More

Insert Spaces and Tabs in Text Using HTML and CSS

Akif Jaseem
Updated on 28-Nov-2024 10:29:16

279 Views

To insert spaces/tabs in text using HTML and CSS, can be tricky as HTML generally doesn't recognize multiple spaces or tabs by default. If you add extra spaces in your code, they'll collapse into a single space when displayed in the browser. We will be understanding three different approaches to insert spaces in text. In this article we are having some text content, our task is to insert Spaces/Tabs in text using HTML and CSS. Approaches to Insert Spaces/Tabs in Text Using HTML Entities for Spaces Using CSS margin or ... Read More

Advertisements