'react_toastify__WEBPACK_IMPORTED_MODULE_3__.toast.configure is not a function

I'm trying to add toast notifications to my project. For some reason after adding

toast.configure();

code is not working and I have error:

react_toastify__WEBPACK_IMPORTED_MODULE_3__.toast.configure is not a function

error image

Here is my code:

import {toast} from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

toast.configure();

function App() {


return(
<div>
if(error){
toast.error("error message...!"); 
}
<div>
)
}

Why am I getting this error? I have installed toast-notifications.

Thank you in advance.



Solution 1:[1]

New version just came out. Try to install React Toastify by adding a specific version. In my case, 8.2.0 works.

- npm i [email protected]
- yarn add [email protected]

Solution 2:[2]

In the latest version (9), toast.configure is removed because "It does not work with react context because it creates a new react tree."

You can add ToastContainer at the top of the document to fix this.

<ToastContainer
    autoClose={5000}
    hideProgressBar={true}
    {...otherPropsFromToastConfigure}
/>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sagar Darekar
Solution 2 Mahesh Samudra