aaronsajo / feedly-by-aaronsajo

feedly-by-aaronsajo.vercel.app
MIT License
0 stars 0 forks source link

Doubt- Toaster #16

Closed aaronsajo closed 3 years ago

aaronsajo commented 3 years ago

@karthiknmenon Not able to use Toastr from "@bigbinary/neetoui/v2". Or may be I am using it in the wrong way.

Screenshot 2021-10-28 at 2 53 14 PM

Here copy is a function that being called on onClick.

JaganKaartik commented 3 years ago

@aaronsajo

NeetoUI uses react-toastify so if you look at the code section of the Toastr. You can see a <ToastContainer /> this is a component that react-toastify provides.

Screenshot 2021-10-28 at 8 42 16 PM

Ref: https://www.npmjs.com/package/react-toastify

I'm assuming you have already installed react-toastify, else add this dependency.

yarn add react-toastify

then add import 'react-toastify/dist/ReactToastify.css' to your index.js. Also import the <ToastContainer /> in your main component. (For global availability)

Eg:

  import React from 'react';

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

  function App(){
    const notify = () => toast("Wow so easy!");

    return (
      <div>
        <button onClick={notify}>Notify!</button>
        <ToastContainer />
      </div>
    );
  }

This should get the toastr working as desired.