Saturday 27 May 2017

reactjs - Angular Services in React

I'm coming from Angular, trying to learn React (Native). How do we implement Angular's concept of a "Service" in React?



For example, I would like to do the following:




  1. Get data from external API as json

  2. Do something to data, e.g. modify each item

  3. Make modified data available to multiple components of the app




This is extremely easy and convenient in Angular using a Service, and injecting that Service into any Components that need access to the data.



How is this achieved in React?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...