how to make two-way data transfer through components?
I need to pass a value from a child component to a parent component and back again and idk how to make it
10 Replies
sounds like a good use case for contexts.
https://docs.solidjs.com/concepts/context
doesn't fit
Why?
I need to send it through props
without context
It's possible in React, but it's not possible here
doesn't fit the project structure
I'd like at least a crutch variant
How do you mean through props? Props are sent from the parent to the child component
But those props could be signals, i.e. you could send signal setters to the child
If you don't want context - or stores
Why can't props be a function?
they can
but the easiest way to have a change in child component visible in parent is to forward something that is already reactive
and that's either a setter, or a shared store, context, even a function wrapper around something that's reactive
Then in the ChildComponent you just do:
And it will change in the parent
As I said before, you could send signal setters to the child. That's that.
it's working
thanks