【发布时间】:2022-11-30 21:48:06
【问题描述】:
我使用来自 https://github.com/arnnis/react-native-toast-notifications#readme 的 react-native-toast-notification
我想要定制吐司,如果成功显示绿色吐司,而失败则显示照片上的红色吐司。
我在应用程序中的代码:
import { ToastProvider } from 'react-native-toast-notifications'
<ToastProvider
placement="bottom"
duration={5000}
animationType='slide-in'
animationDuration={250}
textStyle={{ fontSize: 20 }}
offset={50}
successColor="green"
normalColor="red"
offsetTop={30}
offsetBottom={40}
swipeEnabled={true}
renderType={{
custom_type: (toast) => (
<View style={{ padding: 15 }}>
<Text>{toast.message}</Text>
</View>
)
}}>
我在屏幕上的代码:
import { useToast } from "react-native-toast-notifications";
const onSubmit = (data: IEventPasscode) => {
dispatch(
eventEnterPasscode({
body: data,
onSuccess: () => {
toast.show("Hello World"), {
type: "success",
},
onFailure: () => {
return;
},
}),
);
};
【问题讨论】:
标签: reactjs react-native toast react-native-tools