From e1cef864c06e3498525bb2e5ed4dd764f68b19a8 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Sun, 4 Sep 2022 18:35:50 -0500 Subject: [PATCH] fix(types): don't leak internal types (#4) --- src/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 5988961..a56ac32 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -43,19 +43,19 @@ export function traverseFiber(fiber: Fiber, ascending: boolean, selector: FiberS return selected } -declare module 'react' { - namespace __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED { - const ReactCurrentOwner: React.RefObject +interface ReactInternal { + __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { + ReactCurrentOwner: React.RefObject } } +const { ReactCurrentOwner } = (React as unknown as ReactInternal).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + /** * Returns the current react-internal {@link Fiber}. This is an implementation detail of react-reconciler. */ export function useFiber(): Fiber { - const [fiber] = React.useState( - () => React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current!, - ) + const [fiber] = React.useState(() => ReactCurrentOwner.current!) return fiber }