FlashcardNot attempted
Provider hell
Recall it before you reveal
How do you avoid deeply nested providers in App.jsx?
Space to reveal
Show answer & explanation
A ProviderComposer that folds an array of providers with reduceRight:
const Compose = ({ providers, children }) => providers.reduceRight((acc, p) => cloneElement(p, {}, acc), children);Adding a provider becomes a one-line diff. But also question whether every provider needs to be global: colocate state, and use the URL for shareable state.