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: "Signal 是包装可跟踪值的简单 getter 函数。没有什么特别的。这意味着任何包装访问 Signal 的函数实际上都是一个 Signal 并且也是可跟踪的。放在 JSX 中的任何 JavaScript 表达式也是如此。只要它访问一个 Signal，它就会被更新。"
    }), "\n", jsx(_components.p, {
      children: "理解 Solid 中的组件只是执行一次的函数非常重要。确保更新的唯一方法是将 Signal 包裹在计算或 JSX 中。但是，你始终可以通过将表达式包装在函数中来将其提升出来。这样就可以重复使用了。"
    }), "\n", jsxs(_components.p, {
      children: ["让我们通过引入一个 ", jsx(_components.code, {
        children: "doubleCount"
      }), " 函数来更新我们的 Counter ，将计数乘以 2。"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "const"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "doubleCount"
        }), " = (", jsx(_components.span, {
          className: "hljs-params"
        }), ") => ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "count"
        }), "() * ", jsx(_components.span, {
          className: "hljs-number",
          children: "2"
        }), ";\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "然后我们替换读取值位置。"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "return"
        }), " ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "div"
            }), ">"]
          }), "Count: {doubleCount()}", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "div"
            }), ">"]
          })]
        }), ";\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: ["这只是个小示例，展示了 ", jsx(_components.code, {
        children: "doubleCount"
      }), " 可以被内联，然而它说明了如何组合 Signal 以及如何使派生 Signal 可传递。"]
    })]
  });
}
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-5bc7fd3d.js.map
