How to iterate over Object.entries()?

How does one use <index> or <for> together with Object.entries(obj)
function Example() {
const [schema] = createSignal({'paths':{'/foo':{'a':'a'},'/bar':{'b':'b'}}})
return <Index each={Object.entries(schema().paths)}>{(k,i)=><div>{i} - {k()} - {k()[0]} - {k()[1]}</div>}</Index>;
}
function Example() {
const [schema] = createSignal({'paths':{'/foo':{'a':'a'},'/bar':{'b':'b'}}})
return <Index each={Object.entries(schema().paths)}>{(k,i)=><div>{i} - {k()} - {k()[0]} - {k()[1]}</div>}</Index>;
}
this only seems to work for {k()[0]}, and not {k()[1]} Playground example: https://playground.solidjs.com/anonymous/349c6400-367b-4856-938a-8cf5b4208aea In the console it logs: ​Unrecognized value. Skipped inserting {a: 'a'}
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
3 Replies
REEEEE
REEEEE17mo ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
REEEEE
REEEEE17mo ago
You need to stringify k()[1] because you can't display objects as is
FjordWarden
FjordWarden17mo ago
thx, that did the trick
Want results from more Discord servers?
Add your server