Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda