In Astro, when two framework islands share state via a global store, what happens when the state changes?
Think about how reactive state management works across components.
When multiple islands subscribe to a shared state, any change triggers all subscribed islands to update, keeping UI in sync.
Which code snippet correctly passes a shared state object from Astro to two different framework islands?
Look for consistent prop names passed to both islands.
Passing the same prop name 'state' with the shared state object to both islands ensures they receive the same data.
Given two Astro islands sharing a state object, the first island updates correctly, but the second does not reflect changes. What is the most likely cause?
Consider how subscriptions to reactive state work.
If an island does not subscribe or listen to changes in the shared state, it will not update when the state changes.
Which approach best ensures consistent and reactive state sharing between multiple framework islands in Astro?
Think about how to keep multiple components in sync reactively.
A global reactive store or context allows all islands to read and update shared state, triggering updates where needed.
Consider two Astro islands sharing a reactive state object with a counter starting at 0. Island A increments the counter by 1, and Island B increments it by 2. What is the final counter value after both updates?
const sharedState = reactive({ counter: 0 });
// Island A code
sharedState.counter += 1;
// Island B code
sharedState.counter += 2;
console.log(sharedState.counter);Remember that both increments affect the same shared state object.
Starting from 0, Island A adds 1 (total 1), then Island B adds 2 (total 3). The final value is 3.