From f51bbaa72f2f60f9a38849fc846a43c54f1eda3b Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 27 Feb 2025 09:53:00 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=80fix:=20=EC=83=98=ED=94=8C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/sample/SampleReducer.jsx | 115 ------------------------ 1 file changed, 115 deletions(-) delete mode 100644 src/components/sample/SampleReducer.jsx diff --git a/src/components/sample/SampleReducer.jsx b/src/components/sample/SampleReducer.jsx deleted file mode 100644 index c7403c25..00000000 --- a/src/components/sample/SampleReducer.jsx +++ /dev/null @@ -1,115 +0,0 @@ -import { Card, CardBody, Input, Tab, Tabs } from '@nextui-org/react' -import { useEffect, useReducer } from 'react' - -const reducer = (prevState, nextState) => { - return { ...prevState, ...nextState } -} - -const defaultData = { - commonData: 'common', - tabs: [ - { - id: 1, - name: 'tab1', - range: 10, - maker: 'maker1', - law: 'law1', - basis: 'basis1', - }, - { - id: 2, - name: 'tab2', - range: 20, - maker: 'maker2', - law: 'law2', - basis: 'basis2', - }, - { - id: 3, - name: 'tab3', - range: 30, - maker: 'maker3', - law: 'law3', - basis: 'basis3', - }, - { - id: 4, - name: 'tab4', - range: 40, - maker: 'maker4', - law: 'law4', - basis: 'basis4', - }, - ], -} - -export default function SampleReducer() { - const [sampleState, setSampleState] = useReducer(reducer, defaultData) - - const handleChangeTabsData = (newTab) => { - const newTabs = sampleState.tabs.map((t) => { - if (t.id === newTab.id) { - return newTab - } else { - return t - } - }) - setSampleState({ tabs: newTabs }) - } - - useEffect(() => { - console.log('🚀 ~ SampleReducer ~ sampleState:', sampleState) - }, [sampleState]) - - return ( - <> -
공통: {sampleState.commonData}
-
- - {sampleState.tabs.map((s) => ( - - - -
- { - handleChangeTabsData({ ...s, range: e.target.value }) - }} - /> - { - handleChangeTabsData({ ...s, maker: e.target.value }) - }} - /> - { - handleChangeTabsData({ ...s, law: e.target.value }) - }} - /> - { - handleChangeTabsData({ ...s, basis: e.target.value }) - }} - /> -
-
-
-
- ))} -
-
- - ) -}