Skip to content

Commit

Permalink
+ core: add Custom component to render custom content.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Nov 20, 2024
1 parent e3d90a4 commit 31b85a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/core/src/react/components/custom-content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isValidElement} from 'preact';
import {Component, isValidElement} from 'preact';
import {HtmlContent} from './html-content';
import {HElement} from './h-element';
import {LazyContent} from './lazy-content';
Expand Down Expand Up @@ -71,3 +71,9 @@ export function CustomContent(props: CustomContentProps): VNode | null {
}
return <>{result}</>;
}

export class CustomContentClass extends Component<CustomContentProps> {
render(props: CustomContentProps): VNode | null {
return CustomContent(props);
}
}
11 changes: 11 additions & 0 deletions lib/core/src/react/custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {ComponentFromReact} from './component-from-react';
import {CustomContentClass} from './components';
import {CustomContentProps} from './types';

export class Custom extends ComponentFromReact<CustomContentProps, CustomContentClass> {
static NAME = 'Custom';

static Component = CustomContentClass;
}

Custom.register();
1 change: 1 addition & 0 deletions lib/core/src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './preact';
export * from './signals';
export * from './components';
export * from './component-from-react';
export * from './custom';
export * from './types';

0 comments on commit 31b85a8

Please sign in to comment.