More often than not, we want to update a part of an object (state) without updating the whole object. For example, in the following object (fruit), we may want to…
Call parent component function from child component local function in React.js | Example
Earlier we saw how we can call a function in the parent component from a child component using an anonymous function in the child component. In this example, we will learn…
Call function in parent component from child component in React.js | Example
Sometimes we may need to call a function residing in the parent component from the child component. In this example, we have a function named capitalizeTitle() which capitalizes the title passed to…
Different ways to pass props to components in React.js | Examples
React is a very dynamic library by nature. Therefore, there are often multiple ways to attain the same result. Today we’ll see how we can pass objects or values as…
How to bind CSS styles from an object in React | Example
React allows us to bind CSS styles in multiple ways. Some of the popular methods are: Inlining the CSS styles with objects Binding objects to style which already contains the…
Display a list of objects with unique keys in React.js | Example
It is important to append unique keys when rendering a list of objects in React.js. That way, React would know ahead of time whether or not to update a particular…
How to pass a state from child to parent component using callbacks in React.js?
The data flow in React.js is always one-way and follows the top-down approach. That is, you can only pass states using props from parent to child component. However, there's a…
How to pass a functional child component to a parent component in React.js?
The ability to pass a functional child component to a parent component is one of the most powerful features provided by React.js. Here in this tutorial, I'll show you how…