I have a hard time understanding and using this component:
https://www.npmjs.com/package/react-notifications-component
I can get this plugin to work easily on my App.js file as I followed the examples, but i would like to have something like a function that can be used globally in all of my components to create a notification, but I have no idea what to do.
here is something I want:
import React, {Component} from 'react';
import {createNotification} from 'somewhere..';
class RandomComponent extends Component {
constructor(props) {
super(props);
this.doSomething = this.doSomething.bind(this);
}
doSomething() {
/*
* Here we do something
*/
/* Then we create notification for something */
createNotification();
}
}
But then I dont know how i should Implement the createNotification
function..
In my understanding I kind of need to pass the reference from App.js constructor this.notificationDOMRef = React.createRef();
to the createNotification
function for this to work. Is this what I want even a correct approach or what the heck should i do. But thats kind of the way I would like to use the react-notifications-component
.
Any tips on how I can do this or how I should use this to use notifications very simply in all of my components I need to use it?