The one improvement we could make here is to decouple this logic from loading the providers, mainly because anywhere this hook is called the providers will be reloaded. The cleanest way to do this may be to some of this to context, but definitely a future improvement.
Originally posted by @alexkeating in #78 (comment)