Snackbar component for React Native
npm install react-native-snackbar-context --saveor
yarn add react-native-snackbar-contextimport { SnackbarProvider } from "react-native-snackbar-context";
const App: React.FC = () => {
return (
<SnackbarProvider>
/* Other Components */
</SnackbarProvider>
);
}
export default App;| Name | Type | Default |
|---|---|---|
| spaces | object | SnackbarSpaces |
| colorPalette | object | SnackbarColors |
| duration | number | SnackbarDurations.REGULAR |
import {
useSnackbarContext,
SnackbarMessageTypes,
SnackbarDurations
} from "react-native-snackbar-context";
const Component: React.FC = () => {
const { showMessage, hideMessage } = useSnackbarContext();
const handleShowMessage = React.useCallback(() => {
showMessage({
type: SnackbarMessageTypes.SUCCESS,
message: 'React Native Snackbar Context',
duration: SnackbarDurations.FAST,
actions: [{ title: 'OK', onPress: hideMessage }],
});
}, [showMessage, hideMessage])
return (
<Button title={'Show Snackbar'} onPress={handleShowMessage} />
);
}
export default Component;| Name | Type | Default |
|---|---|---|
| message* | string | - |
| type | success | info | warning | error | default | default |
| duration | number | SnackbarDurations.REGULAR |
| actions | object[] | - |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT