Summary

We used Redux in this app, and that shaped the folder structure we use. Although using Redux requires some boilerplate code, it helps break up our codebase in a reasonable way and removes direct dependencies between containers or screens. Redux is definitely a great addition when we need to maintain a shared state between screens, so we will be using it further throughout the rest of this book. In more complex apps, we would need to build more reducers and possibly separate them by domain and use Redux combineReducers. Moreover, we would need to add more actions and create separate files for each group of actions. For example, we would need actions for login, logout, and register, which we could put together in a folder named src/actions/user.js. Then, we should move our image-related actions (currently in index.js) to src/actions/images.js, so we can modify src/actions/index.js to use it as a combinator for the user and images actions in case we want to have the ability to import all the actions in one go.

Redux also helps with testing as it isolates the app's business logic into the reducers, so we can focus on testing them thoroughly.

Mocking the API calls enables us to build a quick prototype for our app. When a backend is available, we can reuse those mockups for test purposes and replace src/api/index.js with real HTTP calls. In any case, it's a good idea to have a separate folder for all our API calls, so we can replace them easily if there are any backend changes.

You also learned how to build platform-specific code (Android-specific in our case), which is a very useful feature for most apps. Some companies prefer to write separate apps for each platform and only reuse their business logic code, which should be very easy in any Redux-based app as it resides in the reducers.

There is no specific API in React Native to control the device's camera, but we can use the react-native-camera module for it. This is an example of a library accessing iOS- and Android-native APIs to expose them in the React Native JavaScript world.

In our next lesson, we will explore and cross that bridge between the native and the JavaScript world in React Native apps by building a messaging application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144