i want to render nothing if the condition fails using react.
below is my code,
function Parent () {
const iconRef = React.createRef();
const iconRect = iconRef && iconRef.getBoundingClientRect();
return(
<button ref={iconRef}/>
<Child iconRect={iconRect}/>
);
}
function Child({iconRect}: Props) {
return (
{iconRect ? (
<div class="wrapper">
<div class="dialog">
//something
</div>
</div>
) : null}
);
}
But this doesnt work . it gives error Syntax error unexpected token ,
could someone help me with this. thanks.
[<>]toolbar button). Stack Snippets support React, including JSX; here's how to do one.Parent(adjacent elements) and one inChild(incorrect use of a JSX expression). The syntax error you describe relates to theChild, but both need fixing. :-)