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: [jsx(_components.p, {
      children: "As you build your applications, you will want to break apart your code for better modularity and reusability. In Solid, the main way of doing that is by creating components."
    }), "\n", jsxs(_components.p, {
      children: ["Components are just functions like the ", jsx(_components.code, {
        children: "HelloWorld()"
      }), " one we've been using so far. What makes them special is that they typically return JSX and can be called by JSX in other components."]
    }), "\n", jsxs(_components.p, {
      children: ["In this example, let's add our ", jsx(_components.code, {
        children: "Nested"
      }), " component to our app. We've defined it in another file, though you can put multiple components in the same file. First we must import it:"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "import"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Nested"
        }), " ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "from"
        }), " ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./nested\""
        }), ";\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "Then we need to add the component to our JSX. Like before, we now have multiple elements we want to return, so we wrap them in a Fragment:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "function"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "App"
        }), "(", jsx(_components.span, {
          className: "hljs-params"
        }), ") {\n  ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "return"
        }), " (\n    ", jsxs(_components.span, {
          className: "xml",
          children: [jsx(_components.span, {
            className: "hljs-tag",
            children: "<>"
          }), "\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "h1"
            }), ">"]
          }), "This is a Header", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "h1"
            }), ">"]
          }), "\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "Nested"
            }), " />"]
          }), "\n    ", jsx(_components.span, {
            className: "hljs-tag",
            children: "</>"
          })]
        }), "\n  );\n}\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: ["When the parent component first renders, it will execute the ", jsx(_components.code, {
        children: "Nested()"
      }), " function and won't call it ever again. All updates are applied by Solid’s reactivity system which we will cover in the next couple of lessons."]
    })]
  });
}
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-0371f91b.js.map
