Skip to content

proposal: allow easier passing in of props #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mihar-22 opened this issue Oct 15, 2019 · 0 comments
Closed

proposal: allow easier passing in of props #59

mihar-22 opened this issue Oct 15, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@mihar-22
Copy link
Collaborator

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.

@mihar-22 mihar-22 added the enhancement New feature or request label Oct 15, 2019
@mihar-22 mihar-22 closed this as completed Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant