Skip to content

Commit 406cb2c

Browse files
docs(SwitchCase): auto-generated docs (toss#216)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: seungrodotlee <seungrodotlee@gmail.com>
1 parent 8aecbf4 commit 406cb2c

3 files changed

Lines changed: 32 additions & 36 deletions

File tree

.pnp.cjs

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/SwitchCase/SwitchCase.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,39 @@
66

77
```ts
88
function SwitchCase(
9-
value: string | number | boolean,
10-
caseBy: Record<string | number | boolean, () => JSX.Element>,
11-
defaultComponent: () => JSX.Element
12-
): JSX.Element;
9+
value: Case,
10+
caseBy: Partial<{ [P in StringifiedValue<Case>]: () => ReactElement | null }>,
11+
defaultComponent: () => ReactElement | null
12+
): ReactElement | null;
1313
```
1414

1515
### Parameters
1616

1717
<Interface
1818
required
1919
name="value"
20-
type="string | number | boolean"
20+
type="Case"
2121
description="The value to compare against. The component associated with the matching key in <code>caseBy</code> will be rendered."
2222
/>
2323

2424
<Interface
2525
required
2626
name="caseBy"
27-
type="Record<string | number | boolean, () => JSX.Element>"
27+
type="Partial<{ [P in StringifiedValue<Case>]: () => ReactElement | null }>"
2828
description="An object that maps values to components to render. The keys represent possible values, and the values are functions returning the corresponding components."
2929
/>
3030

3131
<Interface
32-
required
3332
name="defaultComponent"
34-
type="() => JSX.Element"
33+
type="() => ReactElement | null"
3534
description="The component to render if <code>value</code> does not match any key in <code>caseBy</code>."
3635
/>
3736

3837
### Return Value
3938

4039
<Interface
4140
name=""
42-
type="JSX.Element"
41+
type="ReactElement | null"
4342
description="React component that conditionally renders based on cases."
4443
/>
4544

src/components/SwitchCase/ko/SwitchCase.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
# SwitchCase
22

3-
`SwitchCase`는 주어진 값에 기반하여 선언적으로 컴포넌트를 렌더링할 수 있는 컴포넌트예요, 마치 `switch-case` 문장과 비슷해요. 이는 특정 상태에 따라 다른 컴포넌트를 조건부로 렌더링해야 할 때 유용해요.
3+
`SwitchCase`는 주어진 값에 따라 선언적으로 컴포넌트를 렌더링할 수 있는 컴포넌트예요. 이는 `switch-case` 문과 유사해요. 특정 상태에 따라 다른 컴포넌트를 조건부로 렌더링해야 할 때 유용해요.
44

55
## 인터페이스
66

77
```ts
88
function SwitchCase(
9-
value: string | number | boolean,
10-
caseBy: Record<string | number | boolean, () => JSX.Element>,
11-
defaultComponent: () => JSX.Element
12-
): JSX.Element;
9+
value: Case,
10+
caseBy: Partial<{ [P in StringifiedValue<Case>]: () => ReactElement | null }>,
11+
defaultComponent: () => ReactElement | null
12+
): ReactElement | null;
1313
```
1414

1515
### 파라미터
1616

1717
<Interface
1818
required
1919
name="value"
20-
type="string | number | boolean"
20+
type="Case"
2121
description="비교할 값이에요. <code>caseBy</code>에서 일치하는 키와 연결된 컴포넌트가 렌더링돼요."
2222
/>
2323

2424
<Interface
2525
required
2626
name="caseBy"
27-
type="Record<string | number | boolean, () => JSX.Element>"
28-
description="렌더링할 컴포넌트를 값으로 맵핑하는 객체예요. 키는 가능한 값을 나타내며, 값은 해당 컴포넌트를 반환하는 함수예요."
27+
type="Partial<{ [P in StringifiedValue<Case>]: () => ReactElement | null }>"
28+
description="렌더링할 컴포넌트를 값에 매핑하는 객체예요. 키는 가능한 값을 나타내고, 값은 해당 컴포넌트를 반환하는 함수예요."
2929
/>
3030

3131
<Interface
32-
required
3332
name="defaultComponent"
34-
type="() => JSX.Element"
33+
type="() => ReactElement | null"
3534
description="<code>value</code>가 <code>caseBy</code>의 어떤 키와도 일치하지 않을 때 렌더링할 컴포넌트예요."
3635
/>
3736

3837
### 반환 값
3938

4039
<Interface
4140
name=""
42-
type="JSX.Element"
43-
description="케이스에 따라 조건부로 렌더링하는 리액트 컴포넌트예요."
41+
type="ReactElement | null"
42+
description="케이스에 따라 조건부로 렌더링되는 React 컴포넌트예요."
4443
/>
4544

4645
## 예시
@@ -50,13 +49,13 @@ function App() {
5049
return (
5150
<SwitchCase
5251
value={status}
53-
// 상태 값에 따라 TypeA, TypeB 또는 TypeC를 렌더링해요.
52+
// status 값에 따라 TypeA, TypeB, 또는 TypeC를 렌더링해요.
5453
caseBy={{
5554
a: () => <TypeA />,
5655
b: () => <TypeB />,
5756
c: () => <TypeC />,
5857
}}
59-
// 상태 값이 어떤 케이스와도 일치하지 않으면 Default를 렌더링해요.
58+
// status 값이 어떤 케이스와도 일치하지 않을 때 Default를 렌더링해요.
6059
defaultComponent={() => <Default />}
6160
/>
6261
);

0 commit comments

Comments
 (0)