NativeBase Toast can be used to display quick warning or error messages.
For Toast to work, you need to wrap your topmost component inside <Root> from native-base.
import { Root } from "native-base";
import { StackNavigator } from "react-navigation";
const AppNavigator = StackNavigator(
{
Page: { screen: Page },
}
);
export default () =>
<Root>
<AppNavigator />
</Root>;
Syntax
import React, { Component } from 'react';
import { Container, Header, Content, Toast, Button, Text, Icon } from 'native-base';
export default class ToastExample extends Component {
constructor(props) {
super(props);
this.state = {
showToast: false
}
}
render() {
return (
<Container>
<Header />
<Content padder>
<Button onPress={()=> Toast.show({
text: 'Wrong password!',
position: 'bottom',
buttonText: 'Okay'
})}>
<Text>Toast</Text>
</Button>
</Content>
</Container>
);
}
}Configuration
| Key | Value | Option | Description |
|---|---|---|---|
| text | - | string | The text content to be shown in the toast. |
| buttonText | - | string | The text to be displayed inside the button. |
| position | bottom | top, bottom | Sets position for the toast. |
| type | - | danger,success,warning | Sets context to the Toast. |
| duration | - | integer | Milliseconds after which Toast disappers |

