How to pass multiple props in a single event handler in ReactJS? Last Updated : 06 Nov, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report To pass multiple props in a single event handler in ReactJS we can create a function to handle the event that accepts multiple props or calls multiple methods. It is a normal task while creating a react project to perform multiple operations for some events. PrerequisitesReact JSReact JS PropsTo pass/call the multiple props methods in a single event handler in ReactJS there are two ways to make it work. Table of Content Defining specific methodsUsing anonymous methodsMethod 1: Defining specific methodsWe can make a separate method for the event and call all the props methods in that method. Syntaxconst seperateMethod = () => { props.method1() props.method2()}Method 2: Using anonymous methodsWe can create an anonymous function and call all the props methods inside the anonymous method. Syntax<Component onClick={() => { props.method1(); props.method2()}}></Component>Steps to create React ApplicationStep 1: Create a React application using the following command: npx create-react-app foldernameStep 2: After creating your project folder i.e. foldername, move to it using the following command: cd foldernameProject Structure: Example: Passing multiple props in a single event handler with both methods JavaScript import React from 'react'; export default class App extends React.Component { sayHi = () => { alert("Hi from GFG"); } sayHello = () => { alert("Hello from GFG"); } render() { return ( <div style={{ marginLeft: 50 }}> <Child1 m1={this.sayHi} m2={this.sayHello} > </Child1> <br></br> <Child2 m1={this.sayHi} m2={this.sayHello}> </Child2> </div> ) } } // Method 1 class Child1 extends React.Component { seperatemethod = () => { this.props.m1(); this.props.m2(); } render() { return ( <div> <button onClick={this.seperatemethod}> Hello Hi from GFG </button> </div> ) } } // Method 2 class Child2 extends React.Component { render() { return ( <div> <button onClick={() => { this.props.m1(); this.props.m2(); }} >Hello hi from GFG</button> </div> ) } } Step to Run Application: Run the application using the following command from the root directory of the project: npm startOutput: Now open your browser and go to http://localhost:3000/, you will see the following output: Comment More infoAdvertise with us Next Article How to Pass Data From Child Component To Its Parent In ReactJS ? K KapilChhipa Follow Improve Article Tags : Web Technologies ReactJS React-Questions Similar Reads How To Handle Multiple Input Field In React Form With A Single Function? When building a form in React, especially one with multiple input fields, itâs essential to maintain clean, readable code. A common approach is using a single function to handle all input fields, reducing redundancy and enhancing efficiency. This article will explore how to handle multiple input fie 4 min read How To Pass Props From Parent to Child Component in ReactJS? ReactJS is a powerful library that helps developers build interactive user interfaces by breaking them into reusable components. One of the essential features of React is the ability to pass data between components using props. In React, props allow parent components to send data or functions to chi 3 min read How to bind event handlers in React? Binding event handlers in React is a fundamental concept that ensures interactive and responsive web applications. React, a popular JavaScript library for building user interfaces uses a declarative approach to handle events. This article explores various methods to bind event handlers in React, hig 3 min read How To Implement Multiple Filters In React ? Applying Filters in React applications is important for enhancing user experience by allowing users to customize the displayed content based on their preferences. In this article, we will explore two approaches to implementing Multiple Filters in React. Table of Content Using State HooksUsing Contex 6 min read How to Pass Data From Child Component To Its Parent In ReactJS ? In ReactJS, the flow of data is typically one-way, meaning data is passed from parent to child components using props. However, there are situations where you may need to pass data from a child component back up to its parent component. In this article, we will cover how to pass data from a child co 5 min read How to pass a parameter to an event handler or callback ? In React, to pass a parameter to an event handler or callback simply means to execute that function or code when the event is triggered. It links the events to the respective functions. Prerequisites:React JSEvent HandlersReact JS Class ComponentApproachWe will define a function to create a window a 2 min read Like