You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wiki/component-development.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ Refer to the [testing guide](testing.md) for guidelines on writing and designing
53
53
54
54
Refer to the [Cypress testing guide](cypress-testing.md) for guidelines on when and how to write Cypress tests.
55
55
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.
57
57
58
58
### Testing dev features in local Kibana
59
59
@@ -97,6 +97,12 @@ Refer to the [SASS page][sass] of our documentation site for a guide to writing
97
97
98
98
## TypeScript definitions
99
99
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
+
100
106
### Pass-through props
101
107
102
108
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.
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`:
134
140
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.
0 commit comments