Skip to content

proposal: allow easier passing in of props #59

Closed
@mihar-22

Description

@mihar-22

Problem

Right now when testing Svelte components from what I've seen in the wild and in my own project, passing in props becomes repetitive and seems to be the main Component initialization option used.

To be more precise this statement:

const { /** results */ } = render(Comp, { props: { myProp: 0 } })

Examples in the wild:

Potential Solution

To avoid breaking changes, maybe the render function can accept both direct props AND Component options. So both the following would be valid:

const { /** results */ } = render(Comp, { myProp: 0 })
const { /** results */ } = render(Comp, { props: { myProp: 0 } })

One way to implement this is to contain a dictionary of the Client side component options, and (1) if any are present then pass in the options, (2) otherwise pass in the object directly as props.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions