Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
How to pass button value to another component in React

I want to pass table cell data(URL) to another IFrame component.

The web app is used to preview CSV URL data, Once the URL clicked I want to show the web in the IFrame.

enter image description here

<table className="table table-responsive overflow-x">
  <tbody>
    {items.map((d, x) => (
      <tr key={d.x}>
        <td scope="row">{x + 1}</td>
        <td id="urlcol">
          <button className="btn" onClick={(e) => this.onClick(e)}>
            {d.Link_Address}{" "}
          </button>
        </td>
      </tr>
    ))}
  </tbody>
</table>

Iframe Component

enter image description here

How can I do this?

Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Remove the double qoutes " " from:

<Iframe url="{props.url}" />

Should be like this:

<Iframe url={props.url} />

in general if you want to pass something from Parent component to child component, will be like this:

Parent component:

import React, { useState } from 'react';
import Child from './Child.js';

export default function Parent(){
  //you can put anything in inside useEffect, not only an array
  const [items, setItems] = useState(['item1','item2','item3']);
  const [currentItem, setCurrentItem] = useState('item1');
  
  const changeCurrentItem = (item)=> {
     setCurrentItem(item);
 }

 return (<div>

        {items.map((item, key)=> {return <button key={key} onClick={()=> changeCurrentItem(item)} > {item} </button>})}

        <div className='child-component-container'>
        <Child item={currentItem} />
        </div>

        </div>)
 }



Child component:

import React from 'react';


export default function Child(props){
 
 return (<div>

<p> item from Parent component: {props.item} </p>

</div>);

 }


about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!