I’m trying to pass a react props into a javascript template literal:
function Yuh(props) {
return <a href={`javascript:console.log(${props.i})`}>{props.i} <h2>a</h2></a>
}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<Yuh i='lmao' />);
But I’m getting this error:
Uncaught ReferenceError: lmao is not defined
I tried to replace i='lmao'
with i={5}
and that seems to work. How do I make it so that strings also work?
Thanks!