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: ["JSX allows you to use JavaScript to control the logic flow in the templates. However, without a Virtual DOM, using things like ", jsx(_components.code, {
        children: "Array.prototype.map"
      }), " would wastefully recreate all the DOM nodes on every update. Instead it is common for Reactive libraries to use template helpers. In Solid we wrap them in components."]
    }), "\n", jsxs(_components.p, {
      children: ["The most basic control flow is the conditional. Solid's compiler is smart enough to optimally handle ternaries (", jsx(_components.code, {
        children: "a ? b : c"
      }), ") and boolean expressions (", jsx(_components.code, {
        children: "a && b"
      }), "). However, often it is more readable to use Solid's ", jsx(_components.code, {
        children: "<Show>"
      }), " component."]
    }), "\n", jsx(_components.p, {
      children: "In the example, we would like to show only the appropriate button that reflects the current state (whether the user is logged in). Update the JSX to:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Show"
        }), "\n  when={", jsx(_components.span, {
          className: "hljs-title function_",
          children: "loggedIn"
        }), "()}\n  fallback={", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "onClick"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{toggle}"
            }), ">"]
          }), "Log in", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), ">"]
          })]
        }), "}\n>\n  ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "onClick"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{toggle}"
            }), ">"]
          }), "Log out", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), ">"]
          })]
        }), "\n</", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Show"
        }), ">\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: ["The ", jsx(_components.code, {
        children: "fallback"
      }), " prop acts as the ", jsx(_components.code, {
        children: "else"
      }), " and will show when the condition passed to ", jsx(_components.code, {
        children: "when"
      }), " is not truthy."]
    }), "\n", jsx(_components.p, {
      children: "Now clicking the button will change back and forth like you would expect."
    })]
  });
}
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-aa2e7d48.js.map
