react-native-toast-message icon indicating copy to clipboard operation
react-native-toast-message copied to clipboard

Custom Type not Showing

Open jjspscl opened this issue 2 years ago • 4 comments

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
    });

image

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

jjspscl avatar May 25 '22 05:05 jjspscl

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.

rhfksl avatar Aug 26 '22 01:08 rhfksl

Where are you running Toast?

henrique-in avatar Jan 24 '23 18:01 henrique-in

@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

hendradedis avatar Feb 19 '23 17:02 hendradedis

use error: (props) => { ... } instead of errorToast: (props) => ( ... }

samvoults avatar Jan 30 '24 14:01 samvoults