From b35759c3a057413a9299f60903312fc0a0d490f8 Mon Sep 17 00:00:00 2001 From: Nicolas Chambrier Date: Thu, 9 May 2019 09:24:38 +0200 Subject: [PATCH] feat(hoc): exposes original component as public static member WrappedComponent --- src/withESI.test.tsx | 5 +++++ src/withESI.tsx | 1 + 2 files changed, 6 insertions(+) diff --git a/src/withESI.test.tsx b/src/withESI.test.tsx index 875fcbc..d51041e 100644 --- a/src/withESI.test.tsx +++ b/src/withESI.test.tsx @@ -5,6 +5,11 @@ import withESI from "./withESI"; const Dummy = (props: { name?: string }) =>
Hello {props.name}
; +test("exposes WrappedComponent", () => { + const DummyESI = withESI(Dummy, "id"); + expect(DummyESI).toHaveProperty("WrappedComponent", Dummy); +}); + test("client-side", () => { const DummyESI = withESI(Dummy, "id"); expect(DummyESI.displayName).toBe("WithESI(Dummy)"); diff --git a/src/withESI.tsx b/src/withESI.tsx index 22bdae8..c624923 100644 --- a/src/withESI.tsx +++ b/src/withESI.tsx @@ -26,6 +26,7 @@ export default function withESI

( fragmentID: string ) { return class WithESI extends React.Component

{ + public static WrappedComponent = WrappedComponent; public static displayName = `WithESI(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;