fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.33k stars 676 forks source link

When used with bootstrap, the toast is not displayed. #965

Closed itouoti12 closed 1 year ago

itouoti12 commented 1 year ago

Do you want to request a feature or report a bug? Perhaps a bug due to a conflict. Reporting is the main thing.

What is the current behavior? Toast does not appear when toast.success('hoge'); is executed.

What is the expected behavior? Executing toast.success('hoge'); will display toast.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Detail

I tried to use react-toastify on React with bootstrap installed to use the grid system to display toast, but it did not show up. I tracked down the cause and found that the bootstrap CSS was being applied against react-toastify.

/node_modules/bootstrap/dist/css/bootstrap.min.css

.toast:not(.show) {
    display: none; 
}

This CSS is applied to the following tags <div class="Toastify__toast">... </div>

Workaround

My workaround for this event is to explicitly specify the CSS using the style option.

toast.success('hoge', {
   style:{
      display: 'flex'
   }
 });
TobiTenno commented 1 year ago

heyo! i had a similar problem. I'm using parcel and scss for my main styles. what fixed this for me was importing the main scss styles last in my root styles def.

specifically....


@import '~bootstrap/scss/bootstrap';

/*[... all my other styles ...]*/

@import '~react-toastify/scss/main';