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
Jasmin
Jasmin4mo ago
sounds like a good use case for contexts. https://docs.solidjs.com/concepts/context
Дикий
Дикий4mo ago
doesn't fit
Jasmin
Jasmin4mo ago
Why?
Дикий
Дикий4mo ago
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
high1
high14mo ago
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
Дикий
Дикий4mo ago
Why can't props be a function?
high1
high14mo ago
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
Grahf
Grahf4mo ago
const [value, setValue] = createSignal()

return (
<ChildComponent setValue={setValue} />
)
const [value, setValue] = createSignal()

return (
<ChildComponent setValue={setValue} />
)
Then in the ChildComponent you just do:
props.setValue(5)
props.setValue(5)
And it will change in the parent
high1
high14mo ago
As I said before, you could send signal setters to the child. That's that.
Дикий
Дикий4mo ago
it's working thanks
Want results from more Discord servers?
Add your server
More Posts
Is createRouteAction removed ? Or Replaced ?Hi, I just updated my version of solid-start and cannot find `createRouteAction` in the docs. Can anPassing "up" signals in SolidI am trying to understand how can you go by reading values from signals defined in children componenuseNavigate - navigate(path) throws "computations created outside a `createRoot`" and errorSometimes (not 100% of the time) when a user selects a new category in the UI, the following code se(node:53181) Warning: An error event has already been emitted on the socket.Has anyone ever encountered the problem: ```bash VITE v4.5.2 ready in 435 ms ➜ Local: httpCan't use an image without src/assets/ at the pathI have a problem why can't I use images from the assets folder if there is no src/assets/image.png asolid-router | return Navigate as componentIs there any way to return `<Navigate href="/auth/login" />` as a component rather than an element? Anchor with target="_blank" leading to app's URLI have a link with the `href` set to an external link for an image. When clicking on this link, a neSolid-start site shows blank page when deployed with github-pagesThis is the deploy.yml I used https://nitro.unjs.io/deploy/providers/github-pages repo https://githIs there a way to get Server Reference inside SolidStart? or other way to use webSocketsI just want to know if there is way to get to server reference that would be usable inside Socket.ioPassing data from `event.locals` to FrontendHey folks, I'm super new to solid/solid start, but I'm trying to implement some authentication and I