Options
All
  • Public
  • Public/Protected
  • All
Menu

react-native-magic-modal

Index

Type aliases

NewConfigProps: Partial<ModalProps>

Variables

MagicModalPortal: React.FC = ...
description

A magic portal that should stay on the top of the app component hierarchy for the modal to be displayed.

example
import { MagicModalPortal } from 'react-native-magic-modal';

export default function App() {
return (
<SomeRandomProvider>
<MagicModalPortal /> // <-- On the top of the app component hierarchy
<Router /> // Your app router or something could follow below
</SomeRandomProvider>
);
}
magicModal: { hide: (props?: any) => Promise<void>; show: (newComponent: ModalChildren, newConfig?: Partial<ModalProps>) => Promise<any> } = ...
example
// ...
import { magicModal } from 'react-native-magic-toast';

// ...
const ExampleModal = () => (
<TouchableOpacity onPress={() => magicModal.hide("hey")}>
<Text>Test!</Text>
</TouchableOpacity>
)

const result = await magicModal.show(ExampleModal);
console.log(result); // Returns 'hey' when the modal is closed by the TouchableOpacity.

Type declaration

  • hide: (props?: any) => Promise<void>
      • (props?: any): Promise<void>
      • description

        Hide the current modal.

        Parameters

        • Optional props: any

          Those props will be passed to the show resolve function.

        Returns Promise<void>

        Returns a promise that resolves when the close animation is finished.

  • show: (newComponent: ModalChildren, newConfig?: Partial<ModalProps>) => Promise<any>
      • (newComponent: ModalChildren, newConfig?: Partial<ModalProps>): Promise<any>
      • description

        Show a modal. If a modal is already present, it will close it first before displaying.

        Parameters

        • newComponent: ModalChildren

          Recieves a function that returns a modal component.

        • Optional newConfig: Partial<ModalProps>

          Recieves NewConfigProps to override the default configs.

        Returns Promise<any>

        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 MagicModalHideTypes

modalRefForTests: RefObject<any> = ...

Generated using TypeDoc