1.1.1 • Published 3 years ago

react-native-nested-modals v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-native-nested-modals

react-native-nested-modals

Installation

npm install react-native-modal react-native-nested-modals

This package built on top react-native-modal, make sure it installed in your project

Usage

import { ModalsProvider } from 'react-native-nested-modals';

// ...

 <ModalsProvider>
   <App />
 </ModalsProvider>

Inside the wrapped component

import useNestedModals, { INestedModalsContext, modalsContext } from 'react-native-nested-modals';

// function component
const { openModal, closeModal, closeAllModals }: INestedModalsContext = useNestedModals();

// class component
<modalsContext.Consumer>
  {( openModal, closeModal, closeAllModals }) => ...}
</modalsContext.Consumer>

 

To do - Create method for MyModal props manipulation on run time

Speical types

type TModalProps = {
  withClickOutside?: boolean;  // defalut -> false
  onClickOutside?: () => void; // defalut -> useNestedModals().close  
} & Partial<ModalProps>;


interface INestedModalsContext {
  closeModal: (idx?: number) => void; // default -> modals.length - 1
  openModal: (MyModal: ReactElement, modalProps?: TModalProps) => number; // default -> ( **REQUIRED**, {} ) => new modal idx
  closeAllModals: () => void;
}

List of full react-native-modal ModalProps can be found here

Unlike react-native-modal, isVisibile alwayes set to true, in case you want to close a modal, just call close method.

To do - Support for modalProps manipulation and re-render accords

Full working example

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago