'How do I use imported components in a function in React

I'm trying to add an icon to a popup using a function, and I cant seem to get the image to render using a component or an image src path

function getNodeInfo(n, nodes) {
    console.log(n);
    // console.log(nodes);
    let info = '<div id="cover">';
    info += '<React.Fragment><CloseIcon/></React.Fragment>';
    info +=
      "<img src={\"{closeIcon}\"} className=\"action\" style=\"top: 0px;\" onClick=\"(function(){let status = document.getElementById('nodeInfo').className == 'panel_on' ? 'off' : 'on'; document.getElementById('nodeInfo').className = 'panel_' + status;})();\"/>";
    

How do I get the img src to work?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source