usePluggableView

Hook to register a pluggable view and get a render function

Simplifies pluggable view usage by eliminating duplication:

  • Registers the view declaration once

  • Returns a render function for usage

Installation

import { usePluggableView } from 'uxp/components';

Signature

function usePluggableView(declaration: Omit<PluggableViewDeclaration, 'props'>): (props?: Record<string, any>) => React.ReactNode

Examples

typescript
const renderOtherDetails = usePluggableView({
    viewId: `${App}/details/other`,
    parentViewId: `${App}/details`,
    defaultPage: OtherDetails
});

// Use in render:
return (
    <div>
        {renderOtherDetails({
            location: item,
            loading,
            isPreview
        })}
    </div>
);

Last updated