#How to pass data from child component to parent?
13 messages · Page 1 of 1 (latest)
move the data up into the parent instead
How? Using props?
function ChildComplonent(props) {
...
props.newProperty = some value
}
Is that what you mean?
what are you actually tying to achieve?
Have a look at Context https://www.solidjs.com/tutorial/stores_context
using context, you can use callbacks for "events". you can also use callbacks as props
(AKA <button onClick... )
I just need to pass to the parent which service I've chosen. See on:click event
Actually, I don't need to share that data (services) globally. I just want to make to pass that to Parent
use a callback prop
<Child setSomething={data => {...}} />
props.setSomething(data)
you don't "emit" events. you just call a function passed down from parent
You can also use something like this, if working with event object makes more sense to you: https://github.com/solidjs-community/solid-primitives/tree/main/packages/event-dispatcher#createeventdispatcher