Skip to main content

AlertPopupUI

Overview​

sample-alert-popup

API Usage​

Step 1. create popup​

Using Default

AlertPopup.tsx
import { AlertPopupUI, createPopup } from 'react-native-global-components';
export default createPopup(AlertPopupUI);

or you can override default props

AlertPopup.tsx
import {
AlertPopupUI,
AlertPopupProps,
createPopup,
} from 'react-native-global-components';

const styles: AlertPopupProps['styles'] = StyleSheet.create({
// override default styles
});

export default createPopup((props: AlertPopupProps) => (
<AlertPopupUI {...props} styles={styles} />
));

Step 2. register portal​

App.tsx
const App = () => {
return (
<NavigationContainer>
<RootNavigator />
<AlertPopup.Portal />
</NavigationContainer>
);
};

Step 3. use anywhere​

AlertPopup.show({
title: `Hi I'm Vertical Popup`,
message: 'select how do you feel today',
vertical: true,
options: [
{
text: 'Good 😝',
},
{
text: 'Not Okay 😢',
color: 'green',
},
{
text: `Don't ask me 😡`,
color: 'red',
},
],
});

Props​

message​

message to show

TypeDefaultRequired
stringundefinedYES

title​

title text to show above message

TypeDefaultRequired
stringundefinedNO

options​

options buttons to show. see option interface below

TypeDefaultRequired
AlertPopupOption[][{ text: 'Ok' }]NO
interface AlertPopupOption {
text: string;
onPress?: (text: string) => void;
color?: string;
textStyle?: StyleProp<TextStyle>;
testID?: string;
}

touchableOpacityProps​

touchableOpacity props of button to override default settings

TypeDefaultRequired
TouchableOpacityPropsundefinedNO

vertical​

flag to render options vertically or horizontally

TypeDefaultRequired
booleanfalseNO

fadeAnimationConfig​

fade animation configuration. see useFadeAnimationStyle.

TypeDefaultRequired
FadeAnimationConfigsundefinedNO

headerElement​

header content to render above title

TypeDefaultRequired
ReactElementundefinedNO

footerElement​

footer content to render below message

TypeDefaultRequired
ReactElementundefinedNO

styles​

style object to override default style

TypeDefaultRequired
StylesundefinedNO
interface Styles {
option?: StyleProp<ViewStyle>;
container?: StyleProp<ViewStyle>;
message?: StyleProp<TextStyle>;
title?: StyleProp<TextStyle>;
optionContainer?: StyleProp<ViewStyle>;
messageContainer?: StyleProp<ViewStyle>;
}