react-native-hoc-modal
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

React.hoc.modal

React component for easy create modals

install

npm i react-native-hoc-modal

Examples

Create modal component

// MyFirstModal.jsx
...
import Modal from 'react-hoc-modal';

const MyFirstModal = () => {

	return(<View>
		<Text>Hello, i am you first modal component</Text>
	</View>);
};

export default Modal.withModal(MyFirstModal);

Mount modal component

// App.jsx
...
import MyFirstModal from "./MyFirstModal";
...
const App = () => {
	...
	return(
		...
		<MyFirstModal/>
	);
}

Use modal component

<Button onPress={MyFirstModal.show} title="Show my first modal"/>

If you need update data without 'props', you can use the 'setState' method.

MyFirstModal.setState({testData: 'Hello'});

To get data use the 'state' property in the returned 'useModal' hook object.

const MyFirstModal = () => {
	const {state} = Modal.useModal();

	return(<View>
		<Text>{state?.testData}</Text>
	</View>);
};

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i react-native-hoc-modal

    Weekly Downloads

    1

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    65.5 kB

    Total Files

    23

    Last publish

    Collaborators

    • sergomorello