Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ exports[`Store should show the right display names for special component types 1
▾ <App>
<MyComponent>
<MyComponent> [ForwardRef]
▾ <Anonymous> [ForwardRef]
<MyComponent>
<Custom> [ForwardRef]
<MyComponent> [Memo]
▾ <MyComponent> [Memo]
<MyComponent> [ForwardRef]
Expand Down
9 changes: 9 additions & 0 deletions packages/react-devtools-shared/src/__tests__/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,13 @@ describe('Store', () => {

const MyComponent = (props, ref) => null;
const FowardRefComponent = React.forwardRef(MyComponent);
const FowardRefComponentWithAnonymousFunction = React.forwardRef(() => (
<MyComponent />
));
const FowardRefComponentWithCustomDisplayName = React.forwardRef(
MyComponent,
);
FowardRefComponentWithCustomDisplayName.displayName = 'Custom';
const MemoComponent = React.memo(MyComponent);
const MemoForwardRefComponent = React.memo(FowardRefComponent);
const LazyComponent = React.lazy(() => fakeImport(MyComponent));
Expand All @@ -864,6 +871,8 @@ describe('Store', () => {
<React.Fragment>
<MyComponent />
<FowardRefComponent />
<FowardRefComponentWithAnonymousFunction />
<FowardRefComponentWithCustomDisplayName />
<MemoComponent />
<MemoForwardRefComponent />
<React.Suspense fallback="Loading...">
Expand Down
11 changes: 10 additions & 1 deletion packages/react-devtools-shell/src/app/ElementTypes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ function FunctionComponent() {

const MemoFunctionComponent = memo(FunctionComponent);

const ForwardRefComponent = forwardRef((props, ref) => (
const FowardRefComponentWithAnonymousFunction = forwardRef((props, ref) => (
<ClassComponent ref={ref} {...props} />
));
const ForwardRefComponent = forwardRef(function NamedInnerFunction(props, ref) {
return <ClassComponent ref={ref} {...props} />;
});
const FowardRefComponentWithCustomDisplayName = forwardRef((props, ref) => (
<ClassComponent ref={ref} {...props} />
));
FowardRefComponentWithCustomDisplayName.displayName = 'Custom';

const LazyComponent = lazy(() =>
Promise.resolve({
Expand All @@ -58,6 +65,8 @@ export default function ElementTypes() {
<FunctionComponent />
<MemoFunctionComponent />
<ForwardRefComponent />
<FowardRefComponentWithAnonymousFunction />
<FowardRefComponentWithCustomDisplayName />
<LazyComponent />
</Suspense>
</StrictMode>
Expand Down