From 71bb8b82227757728514f3f64941f52ec53d453c Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 23 Oct 2024 21:41:22 +0900 Subject: [PATCH] Plugins: Deprecate 'withPluginContext' HOC (#66363) Co-authored-by: Mamaduka Co-authored-by: youknowriad Co-authored-by: gziolo --- package-lock.json | 1 + packages/plugins/README.md | 2 ++ packages/plugins/package.json | 1 + packages/plugins/src/components/plugin-context/index.tsx | 7 +++++++ packages/plugins/tsconfig.json | 1 + 5 files changed, 12 insertions(+) diff --git a/package-lock.json b/package-lock.json index 54e428d00e518..05d0817244866 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54856,6 +54856,7 @@ "@babel/runtime": "7.25.7", "@wordpress/components": "*", "@wordpress/compose": "*", + "@wordpress/deprecated": "*", "@wordpress/element": "*", "@wordpress/hooks": "*", "@wordpress/icons": "*", diff --git a/packages/plugins/README.md b/packages/plugins/README.md index bbf70fed553d3..ac2434e51442f 100644 --- a/packages/plugins/README.md +++ b/packages/plugins/README.md @@ -192,6 +192,8 @@ _Returns_ #### withPluginContext +> **Deprecated** 6.8.0 Use `usePluginContext` hook instead. + A Higher Order Component used to inject Plugin context to the wrapped component. _Parameters_ diff --git a/packages/plugins/package.json b/packages/plugins/package.json index a2ce790e0935e..75f0bc554b868 100644 --- a/packages/plugins/package.json +++ b/packages/plugins/package.json @@ -30,6 +30,7 @@ "@babel/runtime": "7.25.7", "@wordpress/components": "*", "@wordpress/compose": "*", + "@wordpress/deprecated": "*", "@wordpress/element": "*", "@wordpress/hooks": "*", "@wordpress/icons": "*", diff --git a/packages/plugins/src/components/plugin-context/index.tsx b/packages/plugins/src/components/plugin-context/index.tsx index c2e6f8eaa232d..3e2d687229011 100644 --- a/packages/plugins/src/components/plugin-context/index.tsx +++ b/packages/plugins/src/components/plugin-context/index.tsx @@ -3,6 +3,7 @@ */ import { createContext, useContext } from '@wordpress/element'; import { createHigherOrderComponent } from '@wordpress/compose'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -34,6 +35,8 @@ export function usePluginContext() { * A Higher Order Component used to inject Plugin context to the * wrapped component. * + * @deprecated 6.8.0 Use `usePluginContext` hook instead. + * * @param mapContextToProps Function called on every context change, * expected to return object of props to * merge with the component's own props. @@ -47,6 +50,10 @@ export const withPluginContext = ( ) => T & PluginContext ) => createHigherOrderComponent( ( OriginalComponent ) => { + deprecated( 'wp.plugins.withPluginContext', { + since: '6.8.0', + alternative: 'wp.plugins.usePluginContext', + } ); return ( props ) => ( { ( context ) => ( diff --git a/packages/plugins/tsconfig.json b/packages/plugins/tsconfig.json index 9a0da807348b2..47c626f9ddedc 100644 --- a/packages/plugins/tsconfig.json +++ b/packages/plugins/tsconfig.json @@ -9,6 +9,7 @@ "references": [ { "path": "../components" }, { "path": "../compose" }, + { "path": "../deprecated" }, { "path": "../element" }, { "path": "../hooks" }, { "path": "../icons" },