callbag-jsx icon indicating copy to clipboard operation
callbag-jsx copied to clipboard

List of constant values

Open sesajad opened this issue 3 years ago • 1 comments

List seems to not work with constant values.

reproduction procedure

<List of={["1", "2", "3"]} each={x => <>{x}</>} />

The code above doesn't work and results in an error (in the browser console)

callbag-jsx.v0.1.13.js:230 Uncaught TypeError: src is not a function
    at callbag-jsx.v0.1.13.js:230:5
    at bind (callbag-jsx.v0.1.13.js:27:7)
    at Object.lifeCycleBind (index-4a222ee7.js:108:9)
    at render-jsx.dom.v0.2.4.js:636:21
    at render-jsx.dom.v0.2.4.js:538:34
    at Array.forEach (<anonymous>)
    at render-jsx.dom.v0.2.4.js:537:27
    at Object.on (index-93332864.js:295:9)
    at index.js:82:39

expected behavior

while the code below runs properly

<List of={["1", "2", "3"]} each={x => <>{x}</>} />

And will generate the output 1 2 3

sesajad avatar Feb 22 '22 12:02 sesajad

Yep <List/> component is for dynamic lists since explicitly known static lists do not need a specialized component, i.e. you basically want this:

["1", "2", "3"].map(x => <>{x}</>)

loreanvictor avatar Feb 22 '22 16:02 loreanvictor