React Native - Guideline
React Native - Guideline
1 NAMING CONVENTIONS
Header.js
FloatingTextInput.js
CustomButton.js
Footer.js
myUtilityFile.js
cookieHelper.js
fetchApi.js
1.3 Unit test files should use the same name as its corresponding file
HeroBanner.js
HeroBanner.test.js
CookieBanner.js
CookieBanner.test.js
globalStyle.js
1.5 All fonts, colors, and font sizes should be in one file
fontsConfig.js
className
onClick
React Native doesn’t have any preferences in this regard. There are a few common approaches
popular in the ecosystem we may want to consider.
2.1 Grouping by Features or Navigation
One of the common approach to structure projects is to locate all main screens in one folder, all
reusable components in one folder and style related files in one folder grouped by feature or
navigation.
3 CODE
To create a new React App follow the React’s recommended standard steps, please check.
https://reactjs.org/docs/create-a-new-react-app.html
Put all imports in order at the very top of the code file.
Make sure all your imports statements are on new lines.
Imports
Types (if required)
Additional variables
Component
- Definitions
- Functions
- Effects
- Additional destructures
Styles (if required)
Exports
Use index.js for each folder to export so that all the imports are referenced on the index.js file.
3.4 Usage of Double Quotes (" ") & Single Quotes (' ')
To avoide the confusion about double quotes (" ") & single quotes (' '), use double quotes (" ") for
JSX attributes and single quotes (' ') for the JS code.
3.14 Split code into respective files, JavaScript, test, and StyleSheet
3.15 Avoid multiple if-else blocks. Instead, use ternary - best for clean code practice
3.17 Use/Create Custom Hooks instead of just putting a useEffect or multiple useStates directly to
your component
3.18 Avoid huge components, split your component into smaller chunks