Skip to content
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

Receiving props from parent #2

Open
jimafisk opened this issue Nov 28, 2021 · 0 comments
Open

Receiving props from parent #2

jimafisk opened this issue Nov 28, 2021 · 0 comments

Comments

@jimafisk
Copy link
Member

Svelte uses syntax like export let propName to import a prop from a parent component. There was some discussion about changing this syntax to make it more clear about the direction of the data flow (sveltejs/svelte#3454), but ultimately the core team decided to keep it because:

  • They require valid JS syntax for their parser
  • The export keyword means "exposing a contract to the outside world"

I'm curious if there is another approach that makes the direction of the prop being passed more clear, while not adding unnecessary boilerplate or introducing too much magic. Potentially could just use let propName without the export keyword and match the prop name being passed from the parent to the variable that's declared in the child component. The child component could override by just setting a value like let propName = "new value".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant