Comments (5)
Do not call it inside render, move the call to componentDidUpdate/componentDidMount
from react-notifications-component.
i tried this as well it didnt helped, it shows same error
TypeError: Cannot read property 'addNotification' of null
from react-notifications-component.
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.
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.
from react-notifications-component.
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)
- TypeError: Cannot read properties of undefined (reading 'addNotification') HOT 2
- Does not display any notifications
- Scrolling when screen is full of notifications HOT 2
- Please fix typo HOT 1
- Notifications are not auto dismissed when browser tab is inactive HOT 3
- Unable to resolve dependency tree error when installing npm packages HOT 4
- Fade In animation suddenly appears instead of playing the animation HOT 3
- uncompatibility with animate.css library HOT 6
- Notifications created in rapid succession may not be removed from the DOM when dismissed HOT 4
- Not all styles are renamed HOT 1
- npm ERR! Missing script: "build:library:dev" HOT 3
- compatibility issue
- The component's test for closing by timeout failed HOT 1
- Store.addNotification is getting called and failing in my tests HOT 4
- 'message' property renders only string, not component HOT 1
- Notification blinks when it appears HOT 2
- Add `top: 0` to rnc__base
- Desktop Notifications as an option
- Typescript: Export Member
- TypeError: this.add is not a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-notifications-component.