React component for easy create modals
npm i react-native-hoc-modal
// 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);
// App.jsx
...
import MyFirstModal from "./MyFirstModal";
...
const App = () => {
...
return(
...
<MyFirstModal/>
);
}
<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>);
};