#How to pass data from child component to parent?

13 messages · Page 1 of 1 (latest)

junior lintel
#

We have props in solid for passing data down to child component. What about the opposite case when I need to pass some data back to the parent component? If I am not mistaken, in Vue.js there is a possibility to emit event from parent to child. How can I do it?

distant path
#

move the data up into the parent instead

junior lintel
#

How? Using props?

#

function ChildComplonent(props) {
...
props.newProperty = some value
}

Is that what you mean?

distant path
#

what are you actually tying to achieve?

onyx meadow
distant path
#

using context, you can use callbacks for "events". you can also use callbacks as props

#

(AKA <button onClick... )

junior lintel
junior lintel
#

Actually, I don't need to share that data (services) globally. I just want to make to pass that to Parent

hollow mortar
#

use a callback prop

<Child setSomething={data => {...}} />


props.setSomething(data)
#

you don't "emit" events. you just call a function passed down from parent