`<Show keyed>` with a function child is not keyed when the function does not have an argument. · Issue #1508 · solidjs/solid · GitHub
Skip to content

<Show keyed> with a function child is not keyed when the function does not have an argument. #1508

Description

@LiQuidProQuo

Describe the bug

it is expected that when passing keyed property to <Show/>
the component will be keyed, by the value of the when condition.
and that the callback will be called every time the value changes.

however solid correctly "key" a callback only if it has an argument.

I work as expected
https://playground.solidjs.com/anonymous/c1601c39-7e7f-4695-ad4f-6ce46b8bbb41

<Show when={cond()} keyed> 
   { (i_have_an_argument) =><b>{Date.now()}</b> }
</Show>

I don't work 😟
https://playground.solidjs.com/anonymous/c9f3f381-b96c-479b-a1ec-9b43ef3d7338

<Show when={cond()} keyed>
  { ()=><b>{ Date.now() }</b> }
</Show>

Note (root cause):

need to support both a callback and a Signal Getter.
the design decision was, that a callback, is a callback only if it has an argument,
if a function without an argument is provided it is assumed to be a reactive getter / signal.

this may look like magic to the average developer but this is as intended

issue is likely going to be closed as wontfix, and maybe a better handling will come in solid 2.0 which can introduce "breaking change" to fix this.

Your Example Website or App

na

Steps to Reproduce the Bug or Issue

na

Expected behavior

it is expected that in the future solid will find a way that when keyed is provided, it assumes that a callback is provided
when the children is a function, and that the function is not a signal.
and then always call the callback when the key value changes (when={key()})

Screenshots or Videos

No response

Platform

playground

Additional context

No response

Activity

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

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions