Skip to content

Commit

Permalink
Document createRef and forwardRef usage
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienharnay committed Dec 11, 2018
1 parent 1a06dd6 commit e72f8fd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ const elementOnly: React.ReactElement = <div /> || <MyComponent />;
```
[⇧ back to top](#table-of-contents)
#### `React.Ref<React.ReactElement<P>>`
Type representing a React ref given as a second argument to a component by `forwardRef`, pointing to a native DOM component (e.g. `<div />`), or a user-defined composite component (e.g. `<MyComponent />`)
```tsx
const Component = forwardRef((props: P, ref: React.Ref<React.ReactElement<P>>) => <Something />);
```
[⇧ back to top](#table-of-contents)
#### `React.RefObject<P>`
Type representing a React ref returned from `createRef`, pointing to a native DOM component (e.g. `<div />`), or a user-defined composite component (e.g. `<MyComponent />`)
```tsx
const ref: React.RefObject<P> = React.createRef<P>();
```
[⇧ back to top](#table-of-contents)
#### `React.ReactNode`
Type representing any possible type of React node (basically ReactElement (including Fragments and Portals) + primitive JS types)
```tsx
Expand Down

0 comments on commit e72f8fd

Please sign in to comment.