0

enter image description here

I used a component as a child as follows, and in the parent component, ie ShowBodyQuestionsForArchive component, I used the child component as follows: {children}

in ShowBodyQuestionsForArchive component(parent) i have another componet As follows:

enter image description here

I want to change the data of ShowImage component in ShowComparetiveItemsForArchive component(child), which is displayed as {children}

zahraei
  • 79
  • 1
  • 9
  • Try giving it as props to the child. https://stackoverflow.com/questions/32370994/how-to-pass-props-to-this-props-children – Amin Darian Apr 04 '21 at 10:56

1 Answers1

0
 const ShowComparativeQuestionForArchive = ({question, number, items}) => {
     changeShowImage(){
        //changedData
     }
       return(
          <ShowBodyQuestionForArchive question = {question} number = {number}> 
               <ShowComparativeItemsForArchive changeShowImage = {changeShowImage()} number = {number} items = {items} />
               {
                showImage ? <ShowImage {changedData} /> //example
               }
          <ShowBodyQuestionForArchive/>
       )
    }

Now call the prop (changeShowImage) in ShowComparativeItemsForArchive

Shyam Kumar
  • 148
  • 9