plentico / pico

Svelte-like reactive UI compiler written in Go
2 stars 0 forks source link

Receiving props from parent #2

Open jimafisk opened 2 years ago

jimafisk commented 2 years ago

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 (https://github.com/sveltejs/svelte/issues/3454), but ultimately the core team decided to keep it because:

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".