DEV Community

Discussion on: ReactJS Tips & Tricks: Avoid Nested Render Functions

Collapse
 
helderberto profile image
Helder Burato Berto

If you are talking about cases like this:

const Component = ({ onClick }) => {
  const handleClick = () => {
    onClick();
  }

  return <button onClick={handleClick}>Click me!</button>;
}
Enter fullscreen mode Exit fullscreen mode

IMO, it's totally unnecessary the handleClick if it is just to trigger the onClick, but if you have some logic to to before trigger the onClick, it make sense to stay there.