Giter Site home page Giter Site logo

Comments (5)

teodosii avatar teodosii commented on May 16, 2024

Do not call it inside render, move the call to componentDidUpdate/componentDidMount

from react-notifications-component.

yashshukla1912 avatar yashshukla1912 commented on May 16, 2024

i tried this as well it didnt helped, it shows same error
TypeError: Cannot read property 'addNotification' of null
error

from react-notifications-component.

teodosii avatar teodosii commented on May 16, 2024

This isn't package related, as I can see in your last post it crashes due to null reference of this.notificationDOMRef.current. Your ref isn't set up or not working properly, can't really tell from the last example.

Package is not tied to onClick event, samples show usage with onClick but it's not limited to that. As long as you have a reference to the component you are able to call addNotification on that instance.

Feel free to clone the repo and play with the samples to see you're not tied to onClick event.

from react-notifications-component.

yashshukla1912 avatar yashshukla1912 commented on May 16, 2024

Thanks for your support @teodosii , it worked but now if i want to load a spinner when a page gets rendered, i get this.notificationDOMRef.current as null. I took help of this link https://stackoverflow.com/a/50019873 where i came to know Refs don’t get set for elements that weren’t rendered but here i want to show loader and success message(notification). i am sharing code, will you please help me out in this error.
ss

from react-notifications-component.

teodosii avatar teodosii commented on May 16, 2024

You want to show both loader and the success notification? These are React related topics, not package related, and it's not really clear for me what you want to achieve. First of all, as the documentation says, you should have the react-notification-component at the top of the DOM tree, not in every component you're using it.

As long as you set a ref to the component, you should be able to call addNotification and removeNotification on that ref instance. It's React related and has nothing to do with the package itself.

from react-notifications-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.