0

When I use React-Toast, It always duplication like the Image. How prevent the duplication? Toast Duplication Like This

    const Login = () => {

  // ========= Loading ============
  if (loading) {
    return <Loading />;
  }

  // ========= Error ============
  if (error) {
    if (error.code === "auth/user-not-found") {
      toast.error("User Not Found !");
    } else if (error.code === "auth/wrong-password") {
      toast.error("Password is Wrong !. ");
    }
  }

  if (user) {return <></>}
};

export default Login;
1
  • I would like to see the API call section. Commented May 5, 2022 at 18:35

1 Answer 1

0

As far as we don't have the full picture of the question, I'd recommend to take your attention on these 2 things:

  • Error message on screenshot is different that you have passed to toast.error . So maybe toast is duplicated in some other place?
  • You can check the documentation of React Tostify (if you're using this library), they have a section about this issue: https://fkhadra.github.io/react-toastify/prevent-duplicate . Usually providing toast-id fixes the issue.

If it doesn't help you, please provide more details (scenario when you have 2 toasts on the page, api section, parent component where Login is used)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.