Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

No Error For Early Returns #15

@rmorshea

Description

@rmorshea

Right now, we don't produce an error for early returns:

@component
def example():
    if True:
        return None
    use_state()  # should produce error

There is no technical reason that this couldn't be supported however, as per this comment:

...semantics get very confusing. What would happen to state below? Would it be reset or preserved? What about effects? Would they be cleaned up (like on unmount) or would they run normally? If you think about it you’ll find cases that are very confusing regardless of the behavior you pick. Therefore, we disallow this pattern altogether. Put early return after calls to Hooks.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions