Skip to content

Commit

Permalink
fix(overmind-react): fix runtime error with react@19 caused by moved …
Browse files Browse the repository at this point in the history
…internals

closes #620
  • Loading branch information
fmal authored and henri-hulski committed Feb 2, 2025
1 parent 4adb93b commit ccb0678
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/overmind-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ function useForceRerender() {
}

let currentComponentInstanceId = 0
const { ReactCurrentOwner } = (React as any)
.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

const {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: oldReactInternals,
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:
newReactInternals,
} = React as any

const useCurrentComponent = () => {
return ReactCurrentOwner &&
ReactCurrentOwner.current &&
ReactCurrentOwner.current.elementType
? ReactCurrentOwner.current.elementType
: {}
return (
oldReactInternals?.ReactCurrentOwner?.current?.elementType ??
newReactInternals?.A?.getOwner?.()?.elementType ??
{}
)
}

const useState = <Context extends IContext<{ state: {} }>>(
Expand Down

0 comments on commit ccb0678

Please sign in to comment.