Skip to content

Switch and Match Components in Suspense #119

Closed

Description

@yuens1002
<Suspense fallback={<LoadingSpinner />}>
    <Switch>
        <Match when={state.activeTab === 1}>...</Match>
        <Match when={state.activeTab === 2}>...</Match>
        <Match when={state.activeTab === 3}>...</Match>
    </Switch>
</Suspense>

the switch and match components seem to come from thin air. they are not referenced anywhere in the code or in the docs. If you're saying they are helper components, shouldnt they be brought in from an import like how it's done with Suspense? the implementation seems a bit anti-pattern.

Activity

  1. ryansolid commented on Feb 13, 2020

    @ryansolid
    Member

    Sorry for the confusion. Solid compiler auto imports a number of built in control flow components from "solid-js/dom"(https://github.com/ryansolid/solid/blob/master/documentation/rendering.md#control-flow) It's from an earlier time before (https://github.com/ryansolid/solid/issues/42). I'm going to update the docs better.

    It is arguable whether this behaviour is beneficial anymore since it is a bit confusing.

  2. yuens1002 commented on Feb 13, 2020

    @yuens1002
    ContributorAuthor

    just curious, have you thought about Vue's directive syntax ie. <s-switch></s-switch> for control/logical flows? but yes, thank you for having this sort of magic in the list of docs.

  3. ryansolid commented on Feb 13, 2020

    @ryansolid
    Member

    My original approach(before the linked rfc) was like that. I used $ but more or less the same. The idea that an intrinsic element that would be compiled away can be used not to confuse things. Ultimately the motivation for the change is now anyone can write control flow. Don't like how For works write your own variant. There is no VDOM here and the template DSL is wide open, so if someone feels they can write it better or has a cool idea they can make it.

    That being said I really liked the auto imports from the original approach so I kept it. But having used TS where it isnt an option I realize it's not that bad. Not doing it sort of takes away from that Svelte magic appeal but I probably shouldn't be concerned with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions