File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
react-devtools-shared/src/__tests__
react-devtools-shell/src/app/ElementTypes Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -618,6 +618,9 @@ exports[`Store should show the right display names for special component types 1
618618 ▾ <App>
619619 <MyComponent>
620620 <MyComponent> [ForwardRef]
621+ ▾ <Anonymous> [ForwardRef]
622+ <MyComponent>
623+ <Custom> [ForwardRef]
621624 <MyComponent> [Memo]
622625 ▾ <MyComponent> [Memo]
623626 <MyComponent> [ForwardRef]
Original file line number Diff line number Diff line change @@ -856,6 +856,13 @@ describe('Store', () => {
856856
857857 const MyComponent = ( props , ref ) => null ;
858858 const FowardRefComponent = React . forwardRef ( MyComponent ) ;
859+ const FowardRefComponentWithAnonymousFunction = React . forwardRef ( ( ) => (
860+ < MyComponent />
861+ ) ) ;
862+ const FowardRefComponentWithCustomDisplayName = React . forwardRef (
863+ MyComponent ,
864+ ) ;
865+ FowardRefComponentWithCustomDisplayName . displayName = 'Custom' ;
859866 const MemoComponent = React . memo ( MyComponent ) ;
860867 const MemoForwardRefComponent = React . memo ( FowardRefComponent ) ;
861868 const LazyComponent = React . lazy ( ( ) => fakeImport ( MyComponent ) ) ;
@@ -864,6 +871,8 @@ describe('Store', () => {
864871 < React . Fragment >
865872 < MyComponent />
866873 < FowardRefComponent />
874+ < FowardRefComponentWithAnonymousFunction />
875+ < FowardRefComponentWithCustomDisplayName />
867876 < MemoComponent />
868877 < MemoForwardRefComponent />
869878 < React . Suspense fallback = "Loading..." >
Original file line number Diff line number Diff line change @@ -35,9 +35,16 @@ function FunctionComponent() {
3535
3636const MemoFunctionComponent = memo ( FunctionComponent ) ;
3737
38- const ForwardRefComponent = forwardRef ( ( props , ref ) => (
38+ const FowardRefComponentWithAnonymousFunction = forwardRef ( ( props , ref ) => (
3939 < ClassComponent ref = { ref } { ...props } />
4040) ) ;
41+ const ForwardRefComponent = forwardRef ( function NamedInnerFunction ( props , ref ) {
42+ return < ClassComponent ref = { ref } { ...props } /> ;
43+ } ) ;
44+ const FowardRefComponentWithCustomDisplayName = forwardRef ( ( props , ref ) => (
45+ < ClassComponent ref = { ref } { ...props } />
46+ ) ) ;
47+ FowardRefComponentWithCustomDisplayName . displayName = 'Custom' ;
4148
4249const LazyComponent = lazy ( ( ) =>
4350 Promise . resolve ( {
@@ -58,6 +65,8 @@ export default function ElementTypes() {
5865 < FunctionComponent />
5966 < MemoFunctionComponent />
6067 < ForwardRefComponent />
68+ < FowardRefComponentWithAnonymousFunction />
69+ < FowardRefComponentWithCustomDisplayName />
6170 < LazyComponent />
6271 </ Suspense >
6372 </ StrictMode >
You can’t perform that action at this time.
0 commit comments