import { jsx, jsxs, Fragment } from 'solid-jsx/jsx-runtime';

/*@jsxRuntime automatic @jsxImportSource solid-jsx*/
const toc = [];
function _createMdxContent(props) {
  const _components = Object.assign({
    p: "p",
    code: "code",
    pre: "pre",
    span: "span"
  }, props.components);
  return jsxs(Fragment, {
    children: [jsxs(_components.p, {
      children: ["You now know how to render lists in Solid with ", jsx(_components.code, {
        children: "<For>"
      }), ", but Solid also provides the ", jsx(_components.code, {
        children: "<Index>"
      }), " component, which will cause less rerenders in certain situations."]
    }), "\n", jsxs(_components.p, {
      children: ["When the array updates, the ", jsx(_components.code, {
        children: "<For>"
      }), " component uses referential equality to compare elements to the last state of the array. But this isn't always desired."]
    }), "\n", jsxs(_components.p, {
      children: ["In JavaScript, primitives (like strings and numbers) are always compared by value. When using ", jsx(_components.code, {
        children: "<For>"
      }), " with primitive values or arrays of arrays, we could cause a lot of unnecessary rendering. If we used ", jsx(_components.code, {
        children: "<For>"
      }), " to map a list of strings to ", jsx(_components.code, {
        children: "<input>"
      }), " fields that could edit each, every change to that value would cause the ", jsx(_components.code, {
        children: "<input>"
      }), " to be recreated."]
    }), "\n", jsxs(_components.p, {
      children: ["The ", jsx(_components.code, {
        children: "<Index>"
      }), " component is provided for these cases. As a rule of thumb, when working with primitives use ", jsx(_components.code, {
        children: "<Index>"
      }), "."]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Index"
        }), " each={", jsx(_components.span, {
          className: "hljs-title function_",
          children: "cats"
        }), "()}>{", jsxs(_components.span, {
          className: "hljs-function",
          children: ["(", jsx(_components.span, {
            className: "hljs-params",
            children: "cat, i"
          }), ") =>"]
        }), "\n  ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "li"
            }), ">"]
          }), "\n    ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "a"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "target"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "\"_blank\""
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "href"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{"
            }), "`", jsx(_components.span, {
              className: "hljs-attr",
              children: "https:"
            }), "//", jsx(_components.span, {
              className: "hljs-attr",
              children: "www.youtube.com"
            }), "/", jsx(_components.span, {
              className: "hljs-attr",
              children: "watch"
            }), "?", jsx(_components.span, {
              className: "hljs-attr",
              children: "v"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "${cat().id}"
            }), "`}>"]
          }), "\n      {i + 1}: {cat().name}\n    ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "a"
            }), ">"]
          }), "\n  ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "li"
            }), ">"]
          })]
        }), "\n}</", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Index"
        }), ">\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: ["It has a similar signature to ", jsx(_components.code, {
        children: "<For>"
      }), ", except this time the item is the signal and the index is fixed. Each rendered node corresponds to a spot in the array. Whenever the data in that spot changes, the signal will update."]
    }), "\n", jsxs(_components.p, {
      children: [jsx(_components.code, {
        children: "<For>"
      }), " cares about each piece of data in your array, and the position of that data can change; ", jsx(_components.code, {
        children: "<Index>"
      }), " cares about each index in your array, and the content at each index can change."]
    })]
  });
}
function MDXContent(props = {}) {
  const {wrapper: MDXLayout} = props.components || ({});
  return MDXLayout ? jsx(MDXLayout, Object.assign({}, props, {
    children: jsx(_createMdxContent, props)
  })) : _createMdxContent(props);
}

export { MDXContent as default, toc };
//# sourceMappingURL=lesson-0b69f499.js.map
