im new to react and have an issue i cant figure out
i have an external object with data, and if the info delivered is an array instead of just one string/value i want to render it as a <ul> with the different array positions as <li>.
how can i add the current html element as 2nd parameter to the function?
because right now i cant add "this" as a parameter to pass back the info into the according table cell
Line 15 is the line that delivers an unexpected result...
import React from "react"
import games from "../../assets/games"
import './style.scss';
function SingleGame(props) {
function checkContent(content, tdcell) {
let listcontent = "<ul>";
for (let i = 0; i < content.length; i++) {
listcontent += "<li>" + content[i] + "</li>"
}
listcontent += "</ul>"
tdcell.innerHTML = listcontent;
}
return (
<div className="singlegame" id={games[props.game].name}>
<div className="singlegame--title">
{games[props.game].name}
</div>
<div className="singlegame--imagecontainer">
<img
className="singlegame--imagecontainer-image"
src={games[props.game].image}
alt={games[props.game].name}
/>
</div>
<table className="singlegame--table">
<tbody>
{Object.keys(games[props.game].details).map(detail => (
<tr key={detail}>
<th><strong>{detail}</strong></th>
<td>{checkContent(games[props.game].details[detail], this)}</td>
</tr>
))}
</tbody>
</table>
</div>
)
}
export default SingleGame