Skip to content

Commit 97a5cd8

Browse files
committed
Improve react-docgen-typescript wiki docs
- Add warning about displayName bug found in dede73b#r799165839 - useful links to our custom react-docgen config/filters + react's docs - lint misc typos/grammar
1 parent dede73b commit 97a5cd8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

wiki/component-development.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Refer to the [testing guide](testing.md) for guidelines on writing and designing
5353

5454
Refer to the [Cypress testing guide](cypress-testing.md) for guidelines on when and how to write Cypress tests.
5555

56-
Refer to the [automated accessibility testing guide](automated-accessibility-testing.md) for info more info on those.
56+
Refer to the [automated accessibility testing guide](automated-accessibility-testing.md) for more info on those.
5757

5858
### Testing dev features in local Kibana
5959

@@ -97,6 +97,12 @@ Refer to the [SASS page][sass] of our documentation site for a guide to writing
9797

9898
## TypeScript definitions
9999

100+
### Generated props docs
101+
102+
We use [react-docgen-typescript](https://github.com/styleguidist/react-docgen-typescript/) combined with some custom [props filters](../scripts/babel/react-docgen-typescript.js) to automatically generate our Props tab/table from our Typescript component types.
103+
104+
> :warning: [react-docgen-typescript currently has a bug](https://github.com/styleguidist/react-docgen-typescript/issues/395) that does not correctly generate props for all components if a file has multiple components that set a `displayName`. To avoid this bug and broken props tables, keep your component files atomic / limited to 1 major component per file.
105+
100106
### Pass-through props
101107

102108
Many of our components use `rest parameters` and the `spread` operator to pass props through to an underlying DOM element. In those instances the component's TypeScript definition needs to properly include the target DOM element's props.
@@ -130,10 +136,10 @@ interface FooProps extends DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElem
130136

131137
### forwardRef
132138

133-
React's `forwardRef` should be used to provide access to the component's outermost element. We impose two additional requirements when using `forwardRef`:
139+
React's [`forwardRef`](https://reactjs.org/docs/forwarding-refs.html) should be used to provide access to the component's outermost element. We impose two additional requirements when using `forwardRef`:
134140

135-
1. use `forwardRef` instead of `React.forwardRef`, otherwise [react-docgen-typescript](https://github.com/styleguidist/react-docgen-typescript/) does not understand it and the component's props will not be rendered in our documentation
136-
2. the resulting component must have a `displayName`, this is useful when the component is included in a snapshot or when inspected in devtools. There is an eslint rule which checks for this.
141+
1. Use `forwardRef` instead of `React.forwardRef`, otherwise [react-docgen-typescript](https://github.com/styleguidist/react-docgen-typescript/) does not understand it and the component's props table will error in our documentation
142+
2. The resulting component must have a `displayName`, which is useful when the component is included in a snapshot or when inspected in devtools. There is an eslint rule which checks for this.
137143

138144
#### Simple forward/pass-through
139145

0 commit comments

Comments
 (0)