Skip to content

Commit 36040b0

Browse files
committed
Mention another type error on class ref
1 parent f066443 commit 36040b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ Check the render method of `C`.
224224

225225
or you receive some sort of null error (e.g. `Cannot read properties of undefined (reading 'a')`) because `ref.current` is always undefined.
226226

227+
Type errors can also occur at `useRef` in a component that uses the component under transformation:
228+
229+
```
230+
test.tsx:1:1 - error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'?
231+
232+
41 const component = React.useRef<C | null>(null);
233+
~
234+
```
235+
227236
#### Cause
228237

229238
Class components receives refs, and the ref points to the instance of the class. Functional components do not receive refs by default.

0 commit comments

Comments
 (0)