question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toast appearing again all together when modal is opened

See original GitHub issue

Reporting a BUG (ReactJs)

Toast is generated as a whole group where is isnt needed.

Bug is only visible at a certain part of the whole project. The part being the parent component of the whole project. After generating the toasts (where its meant to be shown and comes,) if any modal is opened in the parent component, all the toasts that was generated is generated again. Not an issue of any other third party packages, since the modal (in the image) is made from scrap using only pure css.

.ViewProfile-Modal{
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  padding-top: 5px; /* Location of the box */
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.ViewProfile-Modal-open{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.ViewProfile-Modal-content{
  background-color: #fefefe;
  margin: auto;
  margin-bottom: 1px;
  padding: 40px 20px 20px 20px;
  border-radius: 30px;
  border:none;
  width: 25%;
  /* min-height:10vh; */
  position: relative;
}

ToastComponent is called at all files wherever its needed, just before the closing of the main div in each component. The toasts are listed the way they were generated. Versions: “react”: “^16.13.1”, “react-toast-notifications”: “^2.4.0”, “react-toastify”: “^6.0.9”, Screenshot from 2021-03-18 13-47-25

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
fkhadracommented, Mar 18, 2021

So I saw that in every component you import the ToastContainer and the stylesheet. Insert the ToastContainer and the stylesheet only once in your app. For example in index.js, also, inject the CSS there.


ReactDOM.render(
  <React.StrictMode>
    <BrowserRouter>
      <Provider store={store}>
        {/* <PersistGate > */}
          <App />
        {/* </PersistGate> */}
      </Provider>
    </BrowserRouter> 
   <ToastContainer 
                  position="top-right"
                  autoClose={5000}
                  hideProgressBar
                  newestOnTop
                  closeOnClick
                  rtl={false}
                  pauseOnFocusLoss={false}
                  draggable={false}
                  pauseOnHover
    />
  </React.StrictMode>,
  document.getElementById('root')
);
1reaction
Sagr859commented, Mar 18, 2021

Thanks, I’ll check it out. 😉😋😇

On Thu, Mar 18, 2021 at 11:16 PM Fadi Khadra @.***> wrote:

So I saw that in every component you import the ToastContainer and the stylesheet. Insert the ToastContainer and the stylesheet only once in your app. For example in index.js, also, inject the CSS there.

ReactDOM.render( <React.StrictMode> <BrowserRouter> <Provider store={store}> {/* <PersistGate > /} <App /> {/ </PersistGate> */} </Provider> </BrowserRouter> <ToastContainer position="top-right" autoClose={5000} hideProgressBar newestOnTop closeOnClick rtl={false} pauseOnFocusLoss={false} draggable={false} pauseOnHover /> </React.StrictMode>, document.getElementById(‘root’));

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fkhadra/react-toastify/issues/583#issuecomment-802158299, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJTAVEJO3V5WSQ3FV3H3V7TTEI37TANCNFSM4ZMFPVCQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-toastify showing multiple toast - Stack Overflow
I am building a React app with several components and in at least half of them I am using React-notify and it's working...
Read more >
PBS 70 of X — Bootstrap Modals & Toasts
We'll look at a pair of components designed to notify of something — modal dialogue boxes, and so-called toast notifications.
Read more >
Display modal or toast based off case event
Display modal or toast based off case event. Is it possible to have a modal or toast appear on a list view when...
Read more >
Toasts - Bootstrap
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They're built ......
Read more >
Windows 10 Toast Notification Script - imab.dk
This is not supported and will prevent the toast notification from being displayed. Converted all Get-WMIObject to Get-CimInstance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found