5. You want two islands to share a counter state that increments when either button is clicked. Which approach correctly shares and updates the state across both islands?
hard
A. Declare the signal inside one island and import it directly in the other island
B. Declare a shared signal in the parent Astro component and pass it as a prop to both islands with client:load
C. Use local state inside each island without passing props
D. Declare separate signals inside each island and sync them with events
Solution
Step 1: Understand shared state location
Shared signals must live in a common parent to be passed down.
Step 2: Pass the shared signal as props to both islands
Passing the same signal prop lets both islands update and reflect changes.
Step 3: Use client:load to hydrate both islands for interactivity
client:load enables event handling and reactive updates in islands.
Final Answer:
Declare a shared signal in the parent Astro component and pass it as a prop to both islands with client:load -> Option B
Quick Check:
Shared signal in parent + props + client:load = synced islands [OK]
Hint: Keep shared state in parent and pass to islands with client:load [OK]
Common Mistakes:
Declaring separate signals causing unsynced state
Not passing signal as prop to both islands
Importing signal directly between islands (not supported)
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.