diff --git a/packages/mobx-react-lite/src/observer.ts b/packages/mobx-react-lite/src/observer.ts index 9baf579ff..2f4a79928 100644 --- a/packages/mobx-react-lite/src/observer.ts +++ b/packages/mobx-react-lite/src/observer.ts @@ -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 = @@ -137,6 +138,13 @@ export function observer

( ;(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) {