Skip to main content

Basic Usage

Installation

npm install --save rc-toastr

Usage

In the index file of your app add ToastProvider as the following

src/index.js
import { ToastProvider } from 'rc-toastr'
import "rc-toastr/dist/index.css" // import the css file

ReactDOM.render((
<ToastProvider>
<App />
</ToastProvider>
), document.getElementById('root'))

Then anywhere in your app use the useToast hook to have the access to the toast function

src/App.js
import { useToast } from 'rc-toastr'

const App = () => {
const { toast } = useToast()
const sayHello = () => toast.success("Hello World!")
return <button onClick={sayHello}> Say Hello </button>
}

export default App