#Reactivity between two components using qwik
5 messages · Page 1 of 1 (latest)
Hi @pearl cloud. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Hmm, I don't know enough to give you a confident answer yet. The extracts provided do mention an integration of Qwik with Astro, but they don't provide specific details on how to maintain reactivity between two components using Qwik. I recommend checking out the Qwik integration documentation (https://qwik.builder.io/) for more detailed information.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@pearl cloud kapa.ai is still learning and improving, please let us know how it did by reacting below
If the components are inside of one qwik container:
You can pass signals as props, use stores, or use context
https://qwik.builder.io/docs/components/context/#context
Qwik's context is similar to React, and it's also very performant, because of signals 🙂
--
If the components are in separate islands / containers you will need to use either:
- nanostores
- custom events
- global signals (if they get added to qwik)
here is a hacky initial implementation, we aim to improve it for sure! It's on our list
https://stackblitz.com/edit/qwik-starter-tlhhfa?file=src%2Froutes%2Findex.tsx
But if you'd like to get something going across islands / qwik containers here ya go.
Also the qvisible hook that initializes useCount is not ideal. It is similar to a visible task which is what we want to avoid. (which is similar to other frameworks) Ideally, we want to use a useTask$, useComputed$, or sync$ to initialize it.