Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast disappears as soon as appears #138

Open
Yandamuri opened this issue Feb 17, 2021 · 4 comments
Open

Toast disappears as soon as appears #138

Yandamuri opened this issue Feb 17, 2021 · 4 comments

Comments

@Yandamuri
Copy link

This is my Toast configuration

  Toast.show(toastComponent, {
	duration: Toast.durations.LONG,
	position: -99, 
	shadow: false,
	animation: true,
	hideOnPress: true,
	delay: 0,
	backgroundColor: Colors.APP_BACKGROUND
});

As per documentation Toast.durations.LONG means 3500(I ma not sure if it is milliseconds). But in my case Toast disappears as soon as appears. IF I give value 5000 then it remains up to 2 seconds.

  1. Duration is milliseconds or not?
  2. IF it is milliseconds why toast disappears immediately when duration is Toast.durations.LONG(3500)
@shadowgroundz
Copy link

shadowgroundz commented Jun 7, 2021

+1

@clemi-mage-me
Copy link

I had better result after settings the duration param to an absurde number like 1000000000
Since the used time unit is not provided in the documentation i guess it uses nanoseconds ?

@danleveille
Copy link

This happens to me too, but only on Android. It appears and immediately disappears (onShow triggers), and then after the set duration, onHide triggers, even though it was no longer visible.

On iOS, it works fine.

@jacksonABC
Copy link

_show = () => {
    clearTimeout(this._showTimeout);
    if (!this._animating) {
        clearTimeout(this._hideTimeout);
        this._animating = true;
        this._setPointerEvents('auto');
        this.props.onShow && this.props.onShow(this.props.siblingManager);
        Animated.timing(this.state.opacity, {
            toValue: this.props.opacity,
            duration: this.props.animation ? TOAST_ANIMATION_DURATION : 0,
            easing: Easing.out(Easing.ease),
            useNativeDriver: false
        }).start(({finished}) => {
            if (finished) {
                this._animating = !finished;
                this.props.onShown && this.props.onShown(this.props.siblingManager);
                if (this.props.duration > 0) {
                    this._hideTimeout = setTimeout(() => this._hide(), this.props.duration);
                }
            }
        });
    }
};

I found that I just needed to set useNativeDriver to false in the _show function of ToastContainer.js to solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants