Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
extensions.forEach( extension => {
const { childBlocks, name, settings } = extension;
const { available } = getJetpackExtensionAvailability( name );
if ( has( settings, [ 'render' ] ) ) {
// If the extension has a `render` method, it's not a block but a plugin
const pluginName = `jetpack-${ name }`;
const registered = getPlugin( pluginName );
if ( available && ! registered ) {
registerPlugin( pluginName, settings );
} else if ( ! available && registered ) {
unregisterPlugin( pluginName );
}
} else {
const blockName = `jetpack/${ name }`;
const registered = getBlockType( blockName );
if ( available && ! registered ) {
registerBlockType( blockName, settings );
if ( childBlocks ) {
childBlocks.forEach( ( { name: childName, settings: childSettings } ) => {
// This might have been registered by another parent before
if ( ! getBlockType( `jetpack/${ childName }` ) ) {
import * as plugins from '@wordpress/plugins';
plugins.registerPlugin('my-plugin', {
icon: 'welcome-learn-more',
render: () => <h1>Hello World</h1>,
});
plugins.getPlugins();
plugins.getPlugin('my-plugin');
plugins.unregisterPlugin('my-plugin');
interface OwnProps {
foobar: number;
}
interface ContextProps {
iconName: string;
}
type Props = OwnProps & ContextProps;
const Foo = ({ iconName, foobar }: Props) => (
<ul>
<li>{iconName}</li></ul>