0.0.5 • Published 1 year ago

react-native-hoc-modal v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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>);
};
0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago