Adding Actions
Explore how to implement actions in a MobX model to manage liked images in a React Native app. Understand how to update state, use observer wrappers to trigger re-rendering, and handle observable arrays properly so they display instantly in the UI.
Implementing actions to populate our model
Let’s go back to our LikedImages model and add some real code for the addImages action:
The actions function itself holds a reference to the entire array of liked images—this is the self keyword. In the first iteration of the MobX library, we could find uses of a known JavaScript keyword: this.
Unfort ...