Skip to content
Advertisement

How to pass index to child function

Here is the question. I want to pass index of each child element to the function handleChange, but I can’t get it))) When I click on TabPanelItem appears error handleChange is not a function What’s the problem?

Parent Element:

JavaScript

and my child component:

JavaScript

Advertisement

Answer

you made a mistake in this line

JavaScript

you dont handleChange in the tablePanelItem

it should be

JavaScript

and you are executing the function handleChange by doing this

JavaScript

you either pass the handleChange function as the body of an arrow function as the props of the TabPanelItem

JavaScript

then on click that arrow function would be executed

Advertisement