Skip to content

Commit 165e4bb

Browse files
Add note in the code about type inference
1 parent 9974767 commit 165e4bb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

public-types/reflect.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export function reflect<Props, Bind extends BindFromProps<Props>>(config: {
4949
useUnitConfig?: UseUnitConfig;
5050
}): FC<Omit<Props, keyof Bind>>;
5151

52+
// Note: FC is used as a return type, because tests on a real Next.js project showed,
53+
// that if theoretically better option like (props: ...) => React.ReactNode is used,
54+
// then TS type inference works worse in some cases - didn't manage to reproduce it in a reflect type tests though.
55+
//
56+
// It is not clear why it works this way (FC return type is actually compatible with ReactNode), but it seems that FC is the best option here :shrug:
57+
5258
// createReflect types
5359
/**
5460
* Method to create a `reflect` function with a predefined `view` component.

0 commit comments

Comments
 (0)