Quernest / mui-modal-provider

🌞 Context API and Hooks based Modal Provider for react material-ui framework
MIT License
77 stars 10 forks source link

Make it possible to disable provider check errors #86

Closed Quernest closed 10 months ago

Quernest commented 11 months ago

Perhaps the best answer is to:

  1. Have a fallback (destructing is nice)
  2. export the fallback modal (so that my usecase can do an === compare and disable).
  3. Move the exception to the fallback functions.

This would

  1. Allow the existing API.
  2. Fail fast for people who don't do an explicit check
  3. Allow for no provider detection (my usecase)

const modal = useModal();
if (modal === FallbackModal) {
  // disable
} else { 
  const { showModal } = modal;
  // showmaol
}

Originally posted by @michaeltford in https://github.com/Quernest/mui-modal-provider/issues/84#issuecomment-1823582891