Skip to content
Advertisement

(REACT JS) put value on 1 array element from component

I’m trying to give one component the array value at a certain index and assign a value that i want from the child component.

I want it like this because I’m trying to do a survey app and the number of question can be different. this is just a little test that concludes what I want.

the base Component

JavaScript

the component

JavaScript

here is a place I set it up => https://stackblitz.com/edit/react-mfpk5f?file=src%2FApp.js,src%2FComponent.js

every suggestion is highly appreciated!

Advertisement

Answer

parent componentHere i have tried a way to find solution , just keep a callback function in child component and call a function of parent component inside child so that u can pass data to it .

child component

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement