Skip to content

Commit

Permalink
added warning for legacy context types in function components
Browse files Browse the repository at this point in the history
  • Loading branch information
imjordanxd committed Dec 11, 2024
1 parent 1532c2e commit 58b3605
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/mobx-react-lite/src/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { isUsingStaticRendering } from "./staticRendering"
import { useObserver } from "./useObserver"

let warnObserverOptionsDeprecated = true
let warnLegacyContextTypes = true

const hasSymbol = typeof Symbol === "function" && Symbol.for
const isFunctionNameConfigurable =
Expand Down Expand Up @@ -137,6 +138,13 @@ export function observer<P extends object, TRef = {}>(
;(observerComponent as React.FunctionComponent).contextTypes = (
baseComponent as any
).contextTypes

if (process.env.NODE_ENV !== "production" && warnLegacyContextTypes) {
warnLegacyContextTypes = false
console.warn(
`[mobx-react-lite] Support for Legacy Context in function components will be removed in the next major release.`
)
}
}

if (useForwardRef) {
Expand Down

0 comments on commit 58b3605

Please sign in to comment.