Requesting permission
As the preceding introduction explains, we have a lot of functionality to create in this chapter. In order to keep it all in one place, without cluttering up our App.js
, we will create a separate JavaScript class to manage everything to do with notifications. This is a pattern I really like with React, to extract functionality not attached to any one component. In our src/
folder, next to our components
folder, let's create a folder called resources
, and within that, a file called NotificationResource.js
.
The basic outline of our class looks like this:
export default class NotificationResource { }
We create a JavaScript class and export it.
Note
For those unfamiliar with JavaScript classes (especially for those familiar with classes in other languages), I encourage you to read the MDN article explaining the basics, at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes.
Let’s import it in our App.js
before we forget:
import NotificationResource from...