CodeSeven / toastr

Simple javascript toast notifications

Home Page:http://www.toastrjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add import without links necessity

guilhermedjr opened this issue · comments

Is there a way to use toastr (in React apps, for example) without needing to add css and js links in html, just doing imports? I'm really missing this possibility, and I think it's super necessary for other people too.

If this possibility exists, it would be good to see it on the documentation.

There is a npm package that i haven't tried yet.

From the docs i'd say, you'll have to add on your app.js the following (I haven't tried it, im just following intuition):

import 'toastr';

Yet for the css.. unless you use sass or similar, there doesn't seem to be any raw css file to import from the npm package.
image

Hi, sorry for the delay, I just saw your comment now. :)

In my case, the React app didn't have an App.js file, I was working with "modules". But after some more testing I found that yes, it is possible to use imports, directly in the component files.

toast1

Just to have @guilhermedjr answer in raw text:

import * as toastr from 'toastr'
import 'toastr/build/toastr.min.css';