Skip to content

Commit d698fd2

Browse files
Merge pull request #4869 from upupming/v10.x-memo-type-field
feat: add .type property referencing original component
2 parents cf39a4b + e25d0b9 commit d698fd2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compat/src/memo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ export function memo(c, comparer) {
3030
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
3131
Memoed.prototype.isReactComponent = true;
3232
Memoed._forwarded = true;
33+
Memoed.type = c;
3334
return Memoed;
3435
}

compat/test/browser/memo.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,13 @@ describe('memo()', () => {
233233
`<ol><li>A</li><li>B</li><li class="selected">C</li><li>D</li></ol>`
234234
);
235235
});
236+
237+
it('should attach .type pointing to the original component', () => {
238+
function Foo() {
239+
return <div />;
240+
}
241+
const Memoized = memo(Foo);
242+
243+
expect(Memoized.type).to.equal(Foo);
244+
});
236245
});

0 commit comments

Comments
 (0)