solidjs / solid-docs-next

SolidJS Docs.
https://docs.solidjs.com/
208 stars 225 forks source link

[Content]: List Rendering - Index example Improve #798

Open Oc1S opened 1 week ago

Oc1S commented 1 week ago

📚 Subject area/topic

/concepts/control-flow/list-rendering.mdx

📋 Page(s) affected (or suggested, for new content)

https://docs.solidjs.com/concepts/control-flow/list-rendering

📋 Description of content that is out-of-date or incorrect

Example for <Index> is missing a variable declaration for inputs. It's better to call createSignal to get inputs.

  import { createSignal, Index } from "solid-js"

  function FormList() {
+  const [inputs,setInputs]=createSignal(['input1...','input2...','input3...'])
    return(
      <form>
        <Index each={inputs()}>
          {(input, index) => (
            <input
              type="text"
              value={input()}
              onInput={(e) => {
                // update the input value
              }}
            />
          )}
        </Index>
      </form>
  )
}

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response