Create TS compatible version of replaceableComponent

pull/21833/head
Will Hunt 2020-11-30 12:00:54 +00:00
parent b870de14ed
commit be721c5bcb
1 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { func } from 'prop-types';
import * as React from 'react';
import * as sdk from '../index';
@ -38,3 +39,12 @@ export function replaceableComponent(name: string, origComponent: React.Componen
// return a falsey value like `null` when the skin doesn't have a component.
return () => sdk.getComponent(name) || origComponent;
}
/**
* Typescript-compatible version of `replaceableComponent`
* @see replaceableComponent
* @param {string} name The dot-path name of the component being replaced.
*/
export function replaceableComponentTs(name: string) {
return (origComponent: typeof React.Component) => sdk.getComponent(name) || origComponent;
}