Open Shubham-1994 opened 1 year ago
The same issue here. could you please answer us something?
I am also able to reproduce it in Android, IOS works fine.
@vatsalya-honeycomb is there any solution for android?
@calintamas any solution for android?
I was able to reproduce this issue in Android, although it is not a blocker for my application in production, it is definitely something that does not work as expected. It would be great if someone from core team could tell us what steps to follow to avoid this behavior or how we can help to solve it.
I am able to solve this by just keeping
Thanks @Shubham-1994, the second option works!
One more hack is if you are not using default success toast variant then override it with null.
For anyone a little confused like I was, in your ToastConfig add
success: props => null,
The fix noted by @elabayoub doesn't seem to be compatible with version 2.1.5 unfortunately. The index.js file is different and I can't seem to quickly find the equivalent change.
I was having the same issue this worked for me https://github.com/calintamas/react-native-toast-message/issues/226#issuecomment-1009841777
The fix noted by @elabayoub doesn't seem to be compatible with version 2.1.5 unfortunately. The index.js file is different and I can't seem to quickly find the equivalent change.
How about this?
diff --git a/node_modules/react-native-toast-message/lib/src/ToastUI.js b/node_modules/react-native-toast-message/lib/src/ToastUI.js
index bb5ce5c..2720e98 100644
--- a/node_modules/react-native-toast-message/lib/src/ToastUI.js
+++ b/node_modules/react-native-toast-message/lib/src/ToastUI.js
@@ -34,6 +34,7 @@ function renderComponent({ data, options, config, isVisible, show, hide }) {
export function ToastUI(props) {
const { isVisible, options, hide } = props;
const { position, topOffset, bottomOffset, keyboardOffset } = options;
+ if (!isVisible) return (<></>);
return (<AnimatedContainer isVisible={isVisible} position={position} topOffset={topOffset} bottomOffset={bottomOffset} keyboardOffset={keyboardOffset} onHide={hide}>
{renderComponent(props)}
</AnimatedContainer>);
The fix noted by @elabayoub doesn't seem to be compatible with version 2.1.5 unfortunately. The index.js file is different and I can't seem to quickly find the equivalent change.
How about this?
diff --git a/node_modules/react-native-toast-message/lib/src/ToastUI.js b/node_modules/react-native-toast-message/lib/src/ToastUI.js index bb5ce5c..2720e98 100644 --- a/node_modules/react-native-toast-message/lib/src/ToastUI.js +++ b/node_modules/react-native-toast-message/lib/src/ToastUI.js @@ -34,6 +34,7 @@ function renderComponent({ data, options, config, isVisible, show, hide }) { export function ToastUI(props) { const { isVisible, options, hide } = props; const { position, topOffset, bottomOffset, keyboardOffset } = options; + if (!isVisible) return (<></>); return (<AnimatedContainer isVisible={isVisible} position={position} topOffset={topOffset} bottomOffset={bottomOffset} keyboardOffset={keyboardOffset} onHide={hide}> {renderComponent(props)} </AnimatedContainer>);
Thanks this patch worked for me. Although one thing I noticed is now the toast doesn't have the slide off animation, it just disappears. Not a big problem but the slide on animation still works fine 🧐.. Any ideas why?
The fix noted by @elabayoub doesn't seem to be compatible with version 2.1.5 unfortunately. The index.js file is different and I can't seem to quickly find the equivalent change.
How about this?
diff --git a/node_modules/react-native-toast-message/lib/src/ToastUI.js b/node_modules/react-native-toast-message/lib/src/ToastUI.js index bb5ce5c..2720e98 100644 --- a/node_modules/react-native-toast-message/lib/src/ToastUI.js +++ b/node_modules/react-native-toast-message/lib/src/ToastUI.js @@ -34,6 +34,7 @@ function renderComponent({ data, options, config, isVisible, show, hide }) { export function ToastUI(props) { const { isVisible, options, hide } = props; const { position, topOffset, bottomOffset, keyboardOffset } = options; + if (!isVisible) return (<></>); return (<AnimatedContainer isVisible={isVisible} position={position} topOffset={topOffset} bottomOffset={bottomOffset} keyboardOffset={keyboardOffset} onHide={hide}> {renderComponent(props)} </AnimatedContainer>);
Thanks this patch worked for me. Although one thing I noticed is now the toast doesn't have the slide off animation, it just disappears. Not a big problem but the slide on animation still works fine 🧐.. Any ideas why?
Because the component that does the animation does not get rendered at all. So instead of being able to slide offscreen, you just get an empty fragment.
The fix noted by @elabayoub doesn't seem to be compatible with version 2.1.5 unfortunately. The index.js file is different and I can't seem to quickly find the equivalent change.
How about this?
diff --git a/node_modules/react-native-toast-message/lib/src/ToastUI.js b/node_modules/react-native-toast-message/lib/src/ToastUI.js index bb5ce5c..2720e98 100644 --- a/node_modules/react-native-toast-message/lib/src/ToastUI.js +++ b/node_modules/react-native-toast-message/lib/src/ToastUI.js @@ -34,6 +34,7 @@ function renderComponent({ data, options, config, isVisible, show, hide }) { export function ToastUI(props) { const { isVisible, options, hide } = props; const { position, topOffset, bottomOffset, keyboardOffset } = options; + if (!isVisible) return (<></>); return (<AnimatedContainer isVisible={isVisible} position={position} topOffset={topOffset} bottomOffset={bottomOffset} keyboardOffset={keyboardOffset} onHide={hide}> {renderComponent(props)} </AnimatedContainer>);
Thanks this worked for me.
Describe the bug I have declared Toast component in the Root Container. Because of this while any other dialog or popup like Android Permission dialog appears on screen, an Empty toast also shows on top of screen.
Expected behavior Toast should not be displayed until Toast.show is called
Environment (please complete the following information):