react-native-toast-message
react-native-toast-message copied to clipboard
Custom Type not Showing
Describe the bug I have followed the setup instructions where I put a Toast instance in the end of the root component
# App.tsx
const App = () => {
return (
...
<QueryClientProvider client={queryClient}>
<SafeAreaProvider>
<View style={styles.container}>
<MainRouter initialScene={initialScene} />
</View>
</SafeAreaProvider>
</QueryClientProvider>
<Toast config={toastConfig}/>
)
}
# toast.config.tsx
const toastConfig: ToastConfig = {
errorToast: (props) => (
<ErrorToast
{ ...props }
text2NumberOfLines={4}
text2Style={{
height: 50
}}
/>
)
}
When I call/show the toast in a Route/Component it shows the following error
Toast.show({
type: 'errorToast',
text1: 'Something went wrong',
text2: apiErrorExtractor(error),
visibilityTime: 6000
});
Any help would be appreciated
Environment (please complete the following information):
- OS: iOS
- react-native-toast-message version: v2.1.5
- react-native version: v0.66.1
I don't know why but it works when I set config file as v1.
const toastConfig = {
InformationToast: InformationToast,
ErrorToast: ErrorToast
};
it works, but it causes type error. I'm also struggling with that problem.
Where are you running Toast?
@henrique-in , if not show toast , you can try this on navigation container https://github.com/calintamas/react-native-toast-message/blob/2945e4a90e601bd4c02416e431c70414186b0e2b/docs/navigation-usage.md
use error: (props) => { ... }
instead of errorToast: (props) => ( ... }