Skip to content

Commit

Permalink
refactor: 제네릭 선언 타입명 수정 및 주석 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
Largopie committed Nov 26, 2024
1 parent 9d27455 commit ca388a3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/components/_common/Input/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ interface RadioProps<T> {
disabled?: boolean;
}

const Radio = <RadioType extends string>({
children,
value,
disabled = false,
}: PropsWithChildren<RadioProps<RadioType>>) => {
const group = useRadioContext<RadioType>();
const Radio = <T extends string>({ children, value, disabled = false }: PropsWithChildren<RadioProps<T>>) => {
const group = useRadioContext<T>();

return (
<label>
Expand Down
3 changes: 0 additions & 3 deletions src/components/_common/Input/Radio/RadioContext.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createContext, useContext } from 'react';
import type { RadioGroupProps } from './RadioGroup';

// export const createRadioContext = <T>() => createContext({} as RadioGroupProps<T>);
// export const useRadioContext = <T>() => useContext(createRadioContext<T>());

const RadioContext = createContext<RadioGroupProps<any> | null>(null);

export const useRadioContext = <T extends string>() => {
Expand Down
7 changes: 1 addition & 6 deletions src/components/_common/Input/Radio/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ export interface RadioGroupProps<T> {
onChange: (value: T) => void;
}

const RadioGroup = <RadioType extends string>({
children,
name,
value,
onChange,
}: PropsWithChildren<RadioGroupProps<RadioType>>) => {
const RadioGroup = <T,>({ children, name, value, onChange }: PropsWithChildren<RadioGroupProps<T>>) => {
return (
<StyledFieldSet>
<RadioContext.Provider value={{ name, value, onChange }}>{children}</RadioContext.Provider>
Expand Down

0 comments on commit ca388a3

Please sign in to comment.