Clicking the button does nothing.
I've tried passing in the <a href={news.url}>
into the function I use to generate the button. Currently the code shows the link on the button but I'm stumped at how to open a new tab with the provided Url. I've heard a lot of people talking about Router, but it seems to me why do I have to use this for such a simple thing. As usual I overthink these things.
The data is brought in from an object on another file.
import React from 'react';
import PropTypes from 'prop-types';
import './index.css';
import FileName from './filename';
import Subtitle from './subtitle';
const ListItem = ({news}) => (
<tr className="list-item">
<td><FileName news={news} /> <a href={news.url}>{news.url}</a></td>
<HandleClick openUrl={news.url} passLink={<a href={news.url}>{news.url}</a>}/>
<span className="website"></span>
<td><Subtitle news={news}/> </td>
</tr>
)
function HandleClick (props) {
return(
<button onClick={props.passLink}>{props.openUrl} </button>
)
}
export default ListItem
I expect the button to open a new tab in the browser which uses the link I've provided with the props. The button does nothing.