diff --git a/chapter3/src/app/demo/_components/state.tsx b/chapter3/src/app/demo/_components/state.tsx new file mode 100644 index 0000000..7ab37ed --- /dev/null +++ b/chapter3/src/app/demo/_components/state.tsx @@ -0,0 +1,32 @@ +// src/app/demo/_components/state.tsx +'use client'; + +import { Button } from '@/app/_components/shadcn/ui/button'; +import { FC, useState } from 'react'; +import clsx from 'clsx'; + +import $styles from './style.module.css'; + +const StateDemo: FC = () => { + const [count, setCount] = useState(1); + const [isShow, toggleShow] = useState(true); + + return ( +
+

useState Demo

+ {isShow &&

{count}

} +
+ + + +
+
+ ); +}; +export default StateDemo; diff --git a/chapter3/src/app/demo/page.tsx b/chapter3/src/app/demo/page.tsx index 29ffffd..e178c78 100644 --- a/chapter3/src/app/demo/page.tsx +++ b/chapter3/src/app/demo/page.tsx @@ -2,6 +2,7 @@ // ... import { FC } from 'react'; import { Button } from 'antd'; +import StateDemo from './_components/state'; import $styles from './page.module.css'; @@ -15,6 +16,9 @@ const DemoPage: FC = () => ( 3R教室 +
+ +