Reactive Components
component() with Reactive component definition
type ReactiveProps<P> = { [key in keyof P]: P[key] | Ref<P[key]> };
type ReactiveComponent<P> =
(props: UnwrapNestedRefs<ReactiveProps<P>>) => () => ReactElement<any, any> | null;
function component<Props>(componentSetup: ReactiveComponent<Props>)
: FC<ReactiveProps<Props>>;Example
interface Props {
id: string;
data: string;
}
const MyComp = component((props: Props) => {
return () => <div>{props.id} {props.data}</div>
})
const Container = component(() => {
const myCompId: string = 1;
const myCompData = ref('some data');
return () => (
// notice id and data are declared as strings
// but we can pass them as strings or a ref<string>
<MyComp id={myCompId} data={myCompData}/>
)
})Lifecycles
onMounted()
onUnmounted()
Context API
consumeContext()
component.withHandle()
imperativeHandle()
component() with functional component
ReactiveBoundary
Last updated