React: If Else conditions in JSX

In this article, we will see how to add If and If/Else conditions in JSX in React. JSX If condition using && operator If we are just planning to display something conditionally we can use a if condition in JSX. In Javascript, true && expression will evaluate to expression and false && expression evaluates to […]

React: Passing State from Parent to Child Component

In this article, we will see how State can be passed from Parent component to Child Component as props. In the below example, App is a stateful component that has property name initialized in the constructor. It calls Child Component “Hello” and passes the state variable “name” as props.   Parent Component class App extends […]

React : Updating Component State using setState

In this article, we will see how to update Component State in React. Updating Component State in React In React, we can initialize state of a Component in the constructor using this.state. If we need to change the component’s state, we can do the same using setState() method. It takes key-value pairs as arguments, where […]

Create and Render State in React Component

In this article, we will see how to create and access/render state in a React Component. Creating State in React Component We can create state in a React component by using the state property in the Component’s constructor. Syntax for adding state this.state = { // add the state variables } For example, we can […]

Reactjs : How to Pass values and arrays as props to React Component and access them

In this article, we will see how to pass data as props or properties to a component in React.js and how to access the data inside the component. 1. Pass data as props to React Component Syntax to pass data to React Component is as follows : ComponentName propertyName=“propertyValue” Properties can be accessed in React […]