score:0

first of all, you'll have to return some sort of jsx from the component. the early return doesn't help you a lot in this case as the hook will be called only when the name prop changes. the way you have defined your example now can be a cause of memory leaks. the more preferred approach is doing a conditional render like this

{name ? <div onclick={handler}> click me!!!</div> : <div />}

Related Query

More Query from same tag