<Button onClick={handleClick}
variant="contained" size="medium"
style={{backgroundColor:"#4CB04F", color:"white" }} >
Accept
</Button>
<Snackbar
anchorOrigin={{
vertical: "bottom",
horizontal: "right",
}}
open={open} autoHideDuration={3000} onClose={handleClose}
>
<Alert
onClose={handleClose}
severity="success"
>
The file has been Uploaded Successfully
</Alert>
</Snackbar>
Asked
Active
Viewed 250 times
0

Linda Paiste
- 38,446
- 6
- 64
- 102

Kainat
- 9
- 2
-
I assume `on Close` is supposed to be `onclose`? – evolutionxbox Jan 28 '21 at 10:48
-
actually this is not my code i just want to know that if i cann't enter the text and direct click on button then its shows an alert like an error message. – Kainat Jan 28 '21 at 10:50
-
1We can't know what you mean if you don't provide a [mcve]. – evolutionxbox Jan 28 '21 at 10:52
1 Answers
0
You are using the Snackbar component from React Native Paper. If you look at the docs here, you will notice the Snackbar already is an alert, and you should not be adding another Alert inside it.
<Snackbar
visible={visible}
onDismiss={onDismissSnackBar}
action={{
label: 'Undo',
onPress: () => {
// Do something
},
}}>
The file has been Uploaded Successfully
</Snackbar>
In that same example you will find a Button component:
<Button onPress={onToggleSnackBar}>{visible ? 'Hide' : 'Show'}</Button>
This button has an onToggleSnackBar
function. This is where you should check if the text area is empty or not.

p-syche
- 575
- 1
- 5
- 17