Const
Hides all modals in the stack. This function should be used sparingly, as it's generally preferable to hide modals individually from within the modal itself. However, this function can be useful in edge cases. It's also useful for test suites, such as calling hideAll in Jest's beforeEach function as a cleanup step.
Recieves NewConfigProps to override the default configs.
Returns a Promise that resolves with the hide props when the Modal is closed. If it were closed automatically, without the manual use of hide, the return would be one of HideReturn
// ...
import { magicModal } from 'react-native-magic-toast';
// ...
const ExampleModal = () => (
const { hide } = useMagicModal<{ message: string }>();
<Pressable onPress={() => hide({ message: "hey" })}>
<Text>Test!</Text>
</Pressable>
)
const result = magicModal.show(ExampleModal);
console.log(await result.promise); // Returns { reason: MagicModalHideReason.INTENTIONAL_HIDE, message: "hey" } when the modal is closed by the Pressable.
Description
Hides the given modal. Prefer using
hide
fromuseMagicModal
, as it already infers the modalID. You should use themagicModal.hide
function directly only when calling from outside the modal.Param: props
Those props will be passed to the show resolve function.