React native project structure, maximum code reuse
There is so many way to organizing your project , but finally, Here is a structure i like the best , and i'm currently implements this structure to my project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|-src | |
|- components | |
|- scenes | |
|- style | |
|- utils | |
constain.js | |
index.android.js | |
index.ios.js | |
/** details **/ | |
|- components | |
|-BackButton.js | |
|-Button.js | |
|-AwesomeComponent.js | |
|- scenes | |
|-Login | |
|-Login.js | |
|-style.js | |
|-index.js | |
|-Profile | |
|-Profile.js | |
|-style.js | |
|-index.js | |
|- style | |
|-clolor.js | |
|-container.js | |
|-text.js | |
|- utils | |
|-StorageUnit.js | |
|-TextUtils.js | |
/** explain **/ | |
/android: Android native code | |
/build: stores iOS apk and Android app installation packages | |
/ios: iOS native code | |
/public: stores images, audios and other assets | |
/src: JavaScript source files | |
constants.js: I put all constant variables into this file | |
/components: React-native components, such buttons, lists | |
/scenes | |
/style: shared style files, text, colors, etc. | |
/utils: reusable functions | |
index.android.js: Android entry file | |
index.ios.js: iOS entry file | |
/*** Example ***/ | |
TextStyle.js | |
/*start here */ | |
const text = StyleSheet.create({ | |
p: { | |
color: 'black', | |
fontFamily: 'Open Sans', | |
fontSize: 14, | |
}, | |
title: { | |
fontWeight: 'bold', | |
color: 'black', | |
fontFamily: 'Open Sans', | |
fontSize: 20, | |
}, | |
subTitle: { | |
fontWeight: 'bold', | |
color: 'black', | |
fontFamily: 'Open Sans', | |
fontSize: 14, | |
}, | |
data: { | |
color: 'black', | |
fontFamily: 'Open Sans', | |
fontSize: 25, | |
}, | |
}); | |
export default text; | |
/** end of text style here */ | |
How to use: | |
<Text style={text.p}>settings</Text> | |
<Text style={[text.p, {backgroundColor: 'red']}>settings</Text> | |
No comments: