SolidJSS
SolidJS3y ago
3 replies
FjordWarden

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>;
}


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'}
Quickly discover what the solid compiler will generate from your JSX template
Was this page helpful?