Skip to content

RFC: Pass component props to mounted hook #88

@evist0

Description

@evist0

It would be great if the mounted hook had props support. Trigger an event by passing incoming props to it.

type ComponentProps = {
    foo: string
    bar: boolean
}

const $bar = createStore(false);
const mounted = createEvent<ComponentProps>()

const Component: FC<ComponentProps> = ({foo, bar}) => ...

const ComponentReflected = reflect({
    view: Component,
    bind: {
        bar: $bar
    },
    hooks: { mounted }
})

<ComponentReflected foo="awesome"/>

mounted.watch(console.log) // { foo: "awesome", bar: false }

This would simplify the code, since now we have to make a separate gate in Component for such a case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions