Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 9f246bc

Browse files
committed
Show wrapped component in displayName
1 parent fd15cfd commit 9f246bc

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/__tests__/__snapshots__/index.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ exports[`perf higher-order component does not wrap the passed in component when
77
`;
88

99
exports[`perf higher-order component wraps the passed in component when not in production 1`] = `
10-
<Perf
10+
<perf(MyComp)
1111
testProp="1">
1212
<MyComp
1313
testProp="1">
1414
<div
1515
className="my-comp" />
1616
</MyComp>
17-
</Perf>
17+
</perf(MyComp)>
1818
`;

src/__tests__/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ describe('perf higher-order component', () => {
3333
expect(toJson(result)).toMatchSnapshot();
3434
});
3535

36+
it('shows wrapped component in displayName', () => {
37+
const MyComp = () => <div className="my-comp" />;
38+
const MyCompPerf = perf(MyComp);
39+
40+
expect(MyCompPerf.displayName).toContain(MyComp.name);
41+
});
42+
3643
it('starts ReactPerf on mount', () => {
3744
const MyComp = () => <div className="my-comp" />;
3845
const MyCompPerf = perf(MyComp);

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ export default function perf(Target) {
3939
}
4040
}
4141

42+
Perf.displayName = `perf(${Target.displayName || Target.name || 'Component'})`;
4243
return Perf;
4344
}

0 commit comments

Comments
 (0)