@orca-fe/pocket
Version:
UI components by orca-team
31 lines • 1.13 kB
JavaScript
import React from 'react';
import { Button, Space } from 'antd';
import Counter from "./Counter";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Demo1 = () => {
// 在需要交互的父组件中,调用 useStore
var counter = Counter.useStore();
var _counter$useState = counter.useState(),
count = _counter$useState.count;
return /*#__PURE__*/_jsxs("div", {
children: ["\u8BA1\u6570\u56681\uFF08\u72B6\u6001\u5185\u90E8\u7EF4\u62A4\uFF09\uFF1A", /*#__PURE__*/_jsx(Counter, {}), "\u8BA1\u6570\u56682\uFF08\u5916\u90E8\u53EF\u4EA4\u4E92\uFF09\uFF1A", /*#__PURE__*/_jsx(Counter, {
counter: counter
}), /*#__PURE__*/_jsxs("div", {
children: ["\u8BA1\u6570\u56682\u7684\u503C\u662F\uFF1A", count]
}), /*#__PURE__*/_jsxs(Space, {
children: [/*#__PURE__*/_jsx(Button, {
onClick: () => {
counter.minus();
},
children: "\u51CF1"
}), /*#__PURE__*/_jsx(Button, {
onClick: () => {
counter.add();
},
children: "\u52A01"
})]
})]
});
};
export default Demo1;