Skip to content

Commit

Permalink
Changed the signature of createComponentExtension to include null
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Leathem <bleathem@netflix.com>
  • Loading branch information
Brian Leathem committed Mar 18, 2021
1 parent 98e95f7 commit d4f2eba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core-api/src/extensions/extensions.tsx
Expand Up @@ -60,15 +60,18 @@ export function createRoutableExtension<
});
}

// We do not use ComponentType as the return type, since it doesn't let us convey the children prop.
// ComponentType inserts children as an optional prop whether the inner component accepts it or not,
// making it impossible to make the usage of children type safe.
export function createComponentExtension<
T extends (props: any) => JSX.Element
T extends (props: any) => JSX.Element | null
>(options: { component: ComponentLoader<T> }): Extension<T> {
const { component } = options;
return createReactExtension({ component });
}

export function createReactExtension<
T extends (props: any) => JSX.Element
T extends (props: any) => JSX.Element | null
>(options: {
component: ComponentLoader<T>;
data?: Record<string, unknown>;
Expand Down

0 comments on commit d4f2eba

Please sign in to comment.