How to Call Parent Components's Function from Child Component in React ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In React, it is very important to manage communication between components for building flexible and maintainable applications. Sometime, you need to trigger a function defined in a parent component from a child component. In this article, we'll see how to achieve this in React by passing down functions as props from parent to child components. Table of Content The Need for Calling Parent Functions from Child ComponentsPassing Functions as PropsApproach to Call Parent Component function from Child ComponentThe Need for Calling Parent Functions from Child ComponentsIn React, components are arranged in a way to be modular and reusable. However, there are situations where you need to perform actions or trigger functions defined in a parent component from its child components. This can be done whenwe want to handle user interactions, update state, or executing business logic that resides in the parent component. Passing Functions as PropsOne of the core principles of React is the concept of props, which are properties passed from parent components to their children. Along with data, you can also pass functions as props from parent to child components. By doing so, child components gain access to these functions and can invoke them when necessary. Approach to Call Parent Component function from Child Component:Creating a React Application: To create a basic React Application Structure follow the Folder Structure for a React JS Project article.Creating Required files: Create a file called Child.js which calls parent component's function from App.js file Define Parent Function: Create a function in the parent component that you want to call from the child component.Pass Function as Prop: Pass the parent function down to the child component as a prop.Invoke Function in Child: In the child component, call the parent function using the prop passed down from the parent.Handle Function Call: Define the logic to handle the function call in the parent component to perform desired actions.Example: Create the files as shown in folder structure and add the following codes. CSS /* App.css */ * { margin-left: 10px; } button { background-color: blue; padding: 10px 15px; color: #fff; } .parent { width: 27vw; height: 22vh; border: 1px solid black; padding-top: 20px; text-align: center; } JavaScript //App.js import { useState } from "react"; import "./App.css"; import Child from "./Child"; function App() { const [showDescription, setShowDescription] = useState(""); function handleShowDescription(e) { console.log("calling from child component"); setShowDescription(e); } return ( <div className="App"> <h2>Welcome to React Learning</h2> <div className="parent"> <h3>Parent Window</h3> <p>{showDescription}</p> <Child callFunction={handleShowDescription} /> </div> </div> ); } export default App; JavaScript //Child.js function Child({ callFunction }) { function handleClick() { callFunction("I'm the information from child component",) } return ( <div> <button onClick={(e) => handleClick()}>Child Button Click</button> </div> ) } export default Child; Output:http://loclahost:3000 Comment More infoAdvertise with us Next Article How to Call Parent Components's Function from Child Component in React ? S savaridevan Follow Improve Article Tags : Web Technologies ReactJS React-Props Similar Reads How To Call Function Inside Child Component From Parent Component Using useRef hook ? To call a function inside a child component from a parent component, first, create a useRef hook in the parent component. Then, pass this reference as a prop to the child component. In the child component, use this reference wherever needed to access or call the function from the parent.Prerequisite 2 min read How to convert functional component to class component in ReactJS ? ReactJS offers two primary ways of creating components: functional components and class components. While functional components are more concise and easier to reason about, there are situations where class components may be necessary with the flexibility to use lifecycle methods and manage the state 2 min read How to set Parent State from Children Component in ReactJS? To set the parent state from a child component, we use Reactâs unidirectional data flow. Instead of directly passing data, we pass a function that enables the child to send data back to set the parent state.Prerequisites:React JSuseState HookApproachTo set parent state from child component in React, 2 min read How to communicate from parent component to the child component in Angular 9 ? Angular makes the communication between components very easy. In this article, we will learn how to communicate from a parent component to the child component. Approach: Let's create two components: parent child In the parent component, declare the property that you want to receive in the child comp 2 min read When to use a Class Component over a Function Component in ReactJS? ReactJS provides two main ways to create components: Class Components and Function Components. With the introduction of React Hooks in version 16.8, Function Components became more powerful and are now commonly preferred. However, there are still scenarios where Class Components might be a better ch 3 min read Like