Skip to content

Commit f0b7c75

Browse files
committed
feat : 변수명 변경, activeDate => value
1 parent 165fef0 commit f0b7c75

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

package/src/components/Container.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface Iprops {
2121

2222
function Container({ initValue = new Date(), onChange }: Iprops) {
2323
// 인수가 없을 땐 LOCAL 기준 현재 시간을 반환한다.
24-
const [activeDate, setActiveDate] = useState<Date>(initValue);
24+
const [value, setValue] = useState<Date>(initValue);
2525
const [viewDate, setViewDate] = useState<string>(
2626
getFormatDatetime(initValue, 'YYYY-MM-DD')
2727
);
@@ -81,9 +81,9 @@ function Container({ initValue = new Date(), onChange }: Iprops) {
8181
useEffect(() => {
8282
setIsVisible(false);
8383
if (onChange) {
84-
onChange(activeDate);
84+
onChange(value);
8585
}
86-
}, [activeDate, onChange]);
86+
}, [value, onChange]);
8787

8888
// const [centuryPage, setCenturyPage] = useState<number>(0);
8989
// const [decadePage, setDecadePage] = useState<number>(0);
@@ -101,7 +101,7 @@ function Container({ initValue = new Date(), onChange }: Iprops) {
101101
<div className={`${NAME_SPACE}__input-container`}>
102102
<input
103103
type="text"
104-
value={getFormatDatetime(activeDate, 'YYYY-MM-DD')}
104+
value={getFormatDatetime(value, 'YYYY-MM-DD')}
105105
readOnly
106106
onFocus={handleFocus}
107107
/>
@@ -116,7 +116,7 @@ function Container({ initValue = new Date(), onChange }: Iprops) {
116116
/>
117117
<div className={`${NAME_SPACE}__datepicker`}>
118118
{viewType === 'month' && (
119-
<ViewMonth monthPage={monthPage} setActiveDate={setActiveDate} />
119+
<ViewMonth monthPage={monthPage} setValue={setValue} />
120120
)}
121121
{viewType === 'year' && (
122122
<ViewYear

package/src/components/view/Month.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { getFormatDatetime } from '../../utils/datetime';
66

77
interface Iprops {
88
monthPage: number;
9-
setActiveDate: (value: Date) => void;
9+
setValue: (value: Date) => void;
1010
}
1111

12-
function ViewMonth({ monthPage, setActiveDate }: Iprops) {
12+
function ViewMonth({ monthPage, setValue }: Iprops) {
1313
const year = Math.ceil(monthPage / 12);
1414
const month = monthPage % 12 || 12;
1515
const firstDay = new Date(year, month - 1, 1).getDay(); // 이달 1일의 요일
@@ -35,7 +35,7 @@ function ViewMonth({ monthPage, setActiveDate }: Iprops) {
3535
key={i}
3636
title={title}
3737
data-day={day}
38-
onClick={() => setActiveDate(value)}
38+
onClick={() => setValue(value)}
3939
>
4040
{date}
4141
</button>
@@ -55,7 +55,7 @@ function ViewMonth({ monthPage, setActiveDate }: Iprops) {
5555
key={i}
5656
title={title}
5757
data-day={day}
58-
onClick={() => setActiveDate(value)}
58+
onClick={() => setValue(value)}
5959
>
6060
{date}
6161
</button>
@@ -74,7 +74,7 @@ function ViewMonth({ monthPage, setActiveDate }: Iprops) {
7474
key={i}
7575
title={title}
7676
data-day={day}
77-
onClick={() => setActiveDate(value)}
77+
onClick={() => setValue(value)}
7878
>
7979
{date}
8080
</button>

test/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function App() {
99
<div>
1010
<Datepicker
1111
initValue={dateValue}
12-
onChange={(activeDate) => {
13-
console.log('activeDate', activeDate);
12+
onChange={(value) => {
13+
console.log('value', value);
1414
}}
1515
/>
1616
</div>

0 commit comments

Comments
 (0)