Skip to content

Commit 9c3df6c

Browse files
authored
add eps1lon's comment on reactType
1 parent a7e6748 commit 9c3df6c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ADVANCED.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Section 1: Reusable Components/Type Utilities](#section-1-reusable-componentstype-utilities)
1717
* [Higher Order Components](#higher-order-components-hocs)
1818
* [Render Props](#render-props)
19+
* [`as` props (passing a component to be rendered)](#as-props-passing-a-component-to-be-rendered)
1920
* [Types for Conditional Rendering](#types-for-conditional-rendering)
2021
* [Omit attribute from a type](#omit-attribute-from-a-type)
2122
* [Type Zoo](#type-zoo)
@@ -159,6 +160,19 @@ export interface Props {
159160

160161
[Something to add? File an issue](https://github.com/sw-yx/react-typescript-cheatsheet/issues/new).
161162

163+
## `as` props (passing a component to be rendered)
164+
165+
`ReactType` is pretty useful to cover most types that can be passed to createElement e.g.
166+
167+
```tsx
168+
function PassThrough(props: { as: ReactType<any> }) {
169+
const { as: Component } = props;
170+
171+
return <Component />
172+
}
173+
```
174+
175+
[Thanks @eps1lon](https://github.com/sw-yx/react-typescript-cheatsheet/pull/69) for this
162176

163177
## Types for Conditional Rendering
164178

0 commit comments

Comments
 (0)