File tree Expand file tree Collapse file tree
src/components/SwitchCase Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77``` ts
88function SwitchCase(
9- value : string | number ,
10- caseBy : Record <string | number , () => JSX .Element >,
9+ value : string | number | boolean ,
10+ caseBy : Record <string | number | boolean , () => JSX .Element >,
1111 defaultComponent : () => JSX .Element
1212): JSX .Element ;
1313```
@@ -17,14 +17,14 @@ function SwitchCase(
1717<Interface
1818 required
1919 name="value"
20- type="string | number"
20+ type="string | number | boolean "
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, () => JSX.Element>"
27+ type="Record<string | number | boolean , () => JSX.Element>"
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
Original file line number Diff line number Diff line change @@ -17,15 +17,15 @@ type Props<Case> = {
1717 * similar to a `switch-case` statement. It is useful when you need to conditionally render different
1818 * components depending on a specific state.
1919 *
20- * @param {string | number } value - The value to compare against.
20+ * @param {Case } value - The value to compare against.
2121 * The component associated with the matching key in `caseBy` will be rendered.
22- * @param {Record<string | number, () => JSX.Element > } caseBy - An object that maps values to
22+ * @param {Partial<{ [P in StringifiedValue<Case>]: () => ReactElement | null } > } caseBy - An object that maps values to
2323 * components to render. The keys represent possible values, and the values are functions returning
2424 * the corresponding components.
25- * @param {() => JSX.Element } [defaultComponent] - The component to render if `value` does not match
25+ * @param {() => ReactElement | null } [defaultComponent] - The component to render if `value` does not match
2626 * any key in `caseBy`.
2727 *
28- * @returns {JSX.Element } A React component that conditionally renders based on cases.
28+ * @returns {ReactElement | null } A React component that conditionally renders based on cases.
2929 *
3030 * @example
3131 * function App() {
Original file line number Diff line number Diff line change 66
77``` ts
88function SwitchCase(
9- value : string | number ,
10- caseBy : Record <string | number , () => JSX .Element >,
9+ value : string | number | boolean ,
10+ caseBy : Record <string | number | boolean , () => JSX .Element >,
1111 defaultComponent : () => JSX .Element
1212): JSX .Element ;
1313```
@@ -17,14 +17,14 @@ function SwitchCase(
1717<Interface
1818 required
1919 name="value"
20- type="string | number"
20+ type="string | number | boolean "
2121 description="비교할 값이에요. <code >caseBy</code >에서 일치하는 키와 연결된 컴포넌트가 렌더링돼요."
2222/>
2323
2424<Interface
2525 required
2626 name="caseBy"
27- type="Record<string | number, () => JSX.Element>"
27+ type="Record<string | number | boolean , () => JSX.Element>"
2828 description="렌더링할 컴포넌트를 값으로 맵핑하는 객체예요. 키는 가능한 값을 나타내며, 값은 해당 컴포넌트를 반환하는 함수예요."
2929/>
3030
You can’t perform that action at this time.
0 commit comments