Next.js Discord

Discord Forum

Best practices - if () return

Unanswered
Great Skua posted this in #help-forum
Open in Discord
Great SkuaOP
Hey,
    if (!event) {
        return "Event not found."
    }

VS
    if (!event) return "Event not found."


Can you tell me which one is the better approach? And why?

1 Reply

both does the same thing. At the end, it comes down to code style. Many lint config forces you to add braces whereas others don't