I come from the Angular world where I can have a service with methods and properties. Then I can import this class in another file, inject it in the constructor and call the class's members. Now I am working on a mobile app with React Native and Expo. I am wondering if I can do the same dependency injection.
This is what I have so far:
// HttpService.tsimport....export default class HttpService{ private field = ""; public method1 = () => {} public method2 = () => {} private otherMethod = () => {}}
Usage from Component:
// MakeApiCall.tsximport HttpService from "./services/HttpService";export...// HttpService.method1 is not available.
I don't want to new up an instance of HttpService
every time I call the class's members.