Skip to content

Commit 6d6fc90

Browse files
committed
update docusaurus
1 parent 5f08b98 commit 6d6fc90

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

website/src/pages/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,16 +1174,16 @@ An exaggerated example where implementing 10 React components with 5 required pr
11741174
When applicable use **discriminated type** to eliminate optional props, which will decrease complexity on component API and only required props will be passed depending on its use case.
11751175
11761176
```ts
1177-
// ❌ Avoid optional props as they increase complexity of component API
1177+
// ❌ Avoid optional props as they increase complexity and ambiguity in component APIs
11781178
type StatusProps = {
11791179
data?: Products;
11801180
title?: string;
11811181
time?: number;
11821182
error?: string;
11831183
};
11841184

1185-
//Strive to have majority of props required, if that's not possible,
1186-
// use discriminated union for clear intent on component usage
1185+
//Prefer required props. If optional props are unavoidable,
1186+
// use a discriminated union to represent distinct use cases with required props.
11871187
type StatusSuccess = {
11881188
status: 'success';
11891189
data: Products;
@@ -1200,7 +1200,7 @@ type StatusError = {
12001200
error: string;
12011201
};
12021202

1203-
// Discriminated component props 'StatusProps' with no optional properties
1203+
// Discriminated union 'StatusProps' ensures predictable component props with no optionals
12041204
type StatusProps = StatusSuccess | StatusLoading | StatusError;
12051205

12061206
export const Status = (status: StatusProps) => {...

0 commit comments

Comments
 (0)