Skip to content

Commit

Permalink
fix(types): don't leak internal types (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Sep 4, 2022
1 parent 29b426d commit e1cef86
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fiber>
interface ReactInternal {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
ReactCurrentOwner: React.RefObject<Fiber>
}
}

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<Fiber>(
() => React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current!,
)
const [fiber] = React.useState<Fiber>(() => ReactCurrentOwner.current!)
return fiber
}

Expand Down

0 comments on commit e1cef86

Please sign in to comment.