Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Understanding React JS Components and Props

Understanding React JS Components and Props

React JS is a JavaScript library used for building user interfaces. It follows a component-based architecture, where the UI is divided into reusable and independent components. Components are the building blocks of a React application, and they can be thought of as custom HTML elements.

Components in React can be classified into two types: functional components and class components.

1. Functional Components:
– Functional components are defined as JavaScript functions.
– They are simple and easy to understand.
– They receive props (short for properties) as input and return JSX (JavaScript XML) as output.
– Example:
“`jsx
function Greeting(props) {
return

Hello, {props.name}!

;
}
“`

2. Class Components:
– Class components are defined as JavaScript classes that extend the `React.Component` class.
– They have more features and capabilities compared to functional components.
– They also receive props as input and return JSX as output.
– Example:
“`jsx
class Greeting extends React.Component {
render() {
return

Hello, {this.props.name}!

;
}
}
“`

Props are used to pass data from a parent component to its child component(s). They are read-only and cannot be modified by the child component. Props are passed as attributes to the child component when it is used in the parent component’s JSX.

Example usage of components with props:
“`jsx
function App() {
return (





);
}
“`

In the above example, the `App` component renders two `Greeting` components with different names as props. The `Greeting` component receives the `name` prop and displays a personalized greeting.

Props can be accessed in functional components using the `props` parameter, and in class components using `this.props`.

Overall, components and props are fundamental concepts in React JS that enable the creation of reusable and modular UI elements.