Skip to content

Commit e72f8fd

Browse files
authored
Document createRef and forwardRef usage
Fixes piotrwitek#72
1 parent 1a06dd6 commit e72f8fd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ const elementOnly: React.ReactElement = <div /> || <MyComponent />;
134134
```
135135
[⇧ back to top](#table-of-contents)
136136
137+
#### `React.Ref<React.ReactElement<P>>`
138+
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 />`)
139+
```tsx
140+
const Component = forwardRef((props: P, ref: React.Ref<React.ReactElement<P>>) => <Something />);
141+
```
142+
[⇧ back to top](#table-of-contents)
143+
144+
#### `React.RefObject<P>`
145+
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 />`)
146+
```tsx
147+
const ref: React.RefObject<P> = React.createRef<P>();
148+
```
149+
[⇧ back to top](#table-of-contents)
150+
137151
#### `React.ReactNode`
138152
Type representing any possible type of React node (basically ReactElement (including Fragments and Portals) + primitive JS types)
139153
```tsx

0 commit comments

Comments
 (0)