Summary: This article outlines requirements for React Native Apps.
Requirements for React Native Apps
- React native apps must use const as a variable instead of let, var, val whenever possible, make sure to understand the scope differences between them.
- The app must use Functional components for any stateless presentational components you may have in your project instead of creating a whole class to it, for example
const Button = props => {...}
- Avoid using inline styles in your jsx code unless it is strictly necessary. It's ok if you maintain your styling code in a separate file or in the same component class.
- When handling complicated communication between elements in the component tree, you must use a state management tool like redux, bloc, etc.
- When using components that handle lists, lazy loading must be utilized to display the data. Make sure each element in the list has a unique key (no warnings about the list not using a unique key for each element in it should be displayed)
- Lock the project’s dependencies to prevent breaking changes.
-
- For example, instead of this:
"react-native-img-cache": "^1.5.3",
"react-native-fetch-blob": "^0.10.7",
"react-native-linear-gradient": "^2.3.0"
-
- Use this:
"react-native-img-cache": "1.5.3",
"react-native-fetch-blob": "0.10.7",
"react-native-linear-gradient": "2.3.0"
Delete the ^ character from the library dependency in package.json file.
- Avoid filling the render method with too much logic as it affects the perceived responsiveness of your app.
Further recommended reading
https://www.innofied.com/top-10-react-native-best-practices-to-follow/