Skip to content

Commit 63214d4

Browse files
Update forward-create-ref.md
1 parent c8c50f6 commit 63214d4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/basic/getting-started/forward-create-ref.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CssThemeProvider extends PureComponent<Props> {
2121
`forwardRef`:
2222

2323
```tsx
24-
import { forwardRef, ReactNode } from "react";
24+
import { type ReactNode, forwardRef } from "react";
2525

2626
interface Props {
2727
children?: ReactNode;
@@ -42,7 +42,7 @@ export const FancyButton = forwardRef<Ref, Props>((props, ref) => (
4242
This was done [on purpose](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43265/). You can make it immutable if you have to - assign `React.Ref` if you want to ensure nobody reassigns it:
4343

4444
```tsx
45-
import { forwardRef, ReactNode, Ref } from "react";
45+
import { type ReactNode, forwardRef, Ref } from "react";
4646

4747
interface Props {
4848
children?: ReactNode;
@@ -133,9 +133,11 @@ export const ClickableList = forwardRef(ClickableListInner);
133133

134134
```ts
135135
// Add to `index.d.ts`
136-
interface ForwardRefWithGenerics extends React.FC<WithForwardRefProps<Option>> {
136+
import type {FC} from 'react'; // its better to import types like this
137+
138+
interface ForwardRefWithGenerics extends FC<WithForwardRefProps<Option>> {
137139
<T extends Option>(props: WithForwardRefProps<T>): ReturnType<
138-
React.FC<WithForwardRefProps<T>>
140+
FC<WithForwardRefProps<T>>
139141
>;
140142
}
141143

0 commit comments

Comments
 (0)