#React Context default behaviour
2 messages · Page 1 of 1 (latest)
Astro's approach to handling state and context differs from traditional React or Vue methods. When building an Astro website with islands architecture or partial hydration, you may encounter issues when trying to share state between your components using context providers. This is because when partially hydrating components within Astro or Markdown, you can't use these context wrappers.
Astro recommends using Nano Stores for shared client-side storage instead. Nano Stores is a state management solution that works well with Astro's architecture.
However, if you're trying to use React Context within a single Astro island (a single React component), it should theoretically work as usual. If it's not working as expected, it might be due to a specific issue with your implementation or a bug.