How to pass function as a prop in React component

In previous episodes of react, we have learned how to pass props to the components. In this episode, we will see how could we pass the function as a prop to the child component.

Without wasting much time, let’s straight away take a deep dive into code:

At Line 10, we have created the function handleDeleteOptions, this function is being passed to the component of Options at Line 24.

Component Options looks like this —

At Line 50, we are calling the function which is declared in parent component but is being called from child component i.e. Options.

This is how we pass functions from parent to child component!

I will see you in next chapter.

11/100

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store