├── .gitignore ├── README.md ├── index.js ├── lite.js ├── package.json └── web.js /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ***react-native-globals*** 2 | Speeds development up for ***project specific*** components, it assigns react native apis and components to the global scope so you don't have to worry/diagnose several imports for every page/widget. 3 | 4 | 5 | ``` 6 | import 'react-native-globals'; 7 | const TheComponent = class extends React.Component { 8 | displayName: 'TheComponent'; 9 | 10 | constructor (props, context) { 11 | super(props, context); 12 | this.state = {}; 13 | } 14 | 15 | render () { 16 | return ( 17 | 18 | Hi I didn't have to import anything to start making this component 19 | 20 | ); 21 | } 22 | }; 23 | 24 | module.exports = TheComponent; 25 | 26 | ``` 27 | 28 | *note: this is part of the 1% where I feel using global scope is fine and helps development.* 29 | 30 | **Since react-native v 0.44.0 this package will keep inline to react native versioning** -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | //Parent globals 2 | global.React = require('react'); 3 | global.ReactNative = require('react-native'); 4 | global.React.PropTypes = require("prop-types"); 5 | 6 | //React native components 7 | global.ActivityIndicator = ReactNative.ActivityIndicator; 8 | global.Button = ReactNative.Button; 9 | global.FlatList = ReactNative.FlatList; 10 | global.Image = ReactNative.Image; 11 | global.ImageBackground = ReactNative.ImageBackground; 12 | global.KeyboardAvoidingView = ReactNative.KeyboardAvoidingView; 13 | global.Modal = ReactNative.Modal; 14 | global.RefreshControl = ReactNative.RefreshControl; 15 | global.SafeAreaView = ReactNative.SafeAreaView; 16 | global.ScrollView = ReactNative.ScrollView; 17 | global.SectionList = ReactNative.SectionList; 18 | global.StatusBar = ReactNative.StatusBar; 19 | global.StyleSheet = ReactNative.StyleSheet; 20 | global.Switch = ReactNative.Switch; 21 | global.Text = ReactNative.Text; 22 | global.TextInput = ReactNative.TextInput; 23 | global.TouchableHighlight = ReactNative.TouchableHighlight; 24 | global.TouchableNativeFeedback = ReactNative.TouchableNativeFeedback; 25 | global.TouchableOpacity = ReactNative.TouchableOpacity; 26 | global.TouchableWithoutFeedback = ReactNative.TouchableWithoutFeedback; 27 | global.View = ReactNative.View; 28 | global.VirtualizedList = ReactNative.VirtualizedList; 29 | 30 | // APIS 31 | global.AccessibilityInfo = ReactNative.AccessibilityInfo; 32 | global.Alert = ReactNative.Alert; 33 | global.Animated = ReactNative.Animated; 34 | global.AppRegistry = ReactNative.AppRegistry; 35 | global.AppState = ReactNative.AppState; 36 | global.BackHandler = ReactNative.BackHandler; 37 | global.DeviceEventEmitter = ReactNative.DeviceEventEmitter; 38 | global.Dimensions = ReactNative.Dimensions; 39 | global.Easing = ReactNative.Easing; 40 | global.InteractionManager = ReactNative.InteractionManager; 41 | global.Keyboard = ReactNative.Keyboard; 42 | global.LayoutAnimation = ReactNative.LayoutAnimation; 43 | global.Linking = ReactNative.Linking; 44 | global.NativeAppEventEmitter = ReactNative.NativeAppEventEmitter; 45 | global.NativeMethodsMixin = ReactNative.NativeMethodsMixin; 46 | global.NativeModules = ReactNative.NativeModules; 47 | global.PanResponder = ReactNative.PanResponder; 48 | global.PixelRatio = ReactNative.PixelRatio; 49 | global.Platform = ReactNative.Platform; 50 | global.Settings = ReactNative.Settings; 51 | global.Share = ReactNative.Share; 52 | global.StyleSheet = ReactNative.StyleSheet; 53 | global.Systrace = ReactNative.Systrace; 54 | global.Vibration = ReactNative.Vibration; 55 | 56 | //Device info 57 | global.DeviceHeight = Dimensions.get("window").height; 58 | global.DeviceWidth = Dimensions.get("window").width; 59 | 60 | -------------------------------------------------------------------------------- /lite.js: -------------------------------------------------------------------------------- 1 | //Parent globals 2 | import ReactNative from 'react-native'; 3 | 4 | //React native components 5 | global.ActivityIndicator = ReactNative.ActivityIndicator; 6 | global.Button = ReactNative.Button; 7 | global.FlatList = ReactNative.FlatList; 8 | global.Image = ReactNative.Image; 9 | global.ImageBackground = ReactNative.ImageBackground; 10 | global.KeyboardAvoidingView = ReactNative.KeyboardAvoidingView; 11 | global.Modal = ReactNative.Modal; 12 | global.SafeAreaView = ReactNative.SafeAreaView; 13 | global.ScrollView = ReactNative.ScrollView; 14 | global.SectionList = ReactNative.SectionList; 15 | global.StyleSheet = ReactNative.StyleSheet; 16 | global.Switch = ReactNative.Switch; 17 | global.Text = ReactNative.Text; 18 | global.TextInput = ReactNative.TextInput; 19 | global.TouchableOpacity = ReactNative.TouchableOpacity; 20 | global.View = ReactNative.View; 21 | 22 | // APIS 23 | global.Alert = ReactNative.Alert; 24 | global.DeviceEventEmitter = ReactNative.DeviceEventEmitter; 25 | global.Linking = ReactNative.Linking; 26 | global.PixelRatio = ReactNative.PixelRatio; 27 | global.Platform = ReactNative.Platform; 28 | 29 | //Device info 30 | global.DeviceHeight = ReactNative.Dimensions.get("window").height; 31 | global.DeviceWidth = ReactNative.Dimensions.get("window").width; 32 | 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-globals", 3 | "version": "0.64.0", 4 | "description": "Assigns react native components and apis to global scope", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "react-native", 11 | "global", 12 | "boilerplate" 13 | ], 14 | "author": "kyle-ssg", 15 | "license": "ISC", 16 | "peerDependencies": { 17 | "react-native": ">=0.60.0" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/kyle-ssg/react-native-globals.git" 22 | }, 23 | "bugs": { 24 | "url": "https://github.com/kyle-ssg/react-native-globals/issues" 25 | }, 26 | "homepage": "https://github.com/kyle-ssg/react-native-globals#readme" 27 | } 28 | -------------------------------------------------------------------------------- /web.js: -------------------------------------------------------------------------------- 1 | //Parent globals 2 | global.React = require('react'); 3 | global.ReactNative = require('react-native-web'); 4 | global.React.PropTypes = require("prop-types"); 5 | 6 | //React native components 7 | global.ActivityIndicator = ReactNative.ActivityIndicator; 8 | global.Button = ReactNative.Button; 9 | global.FlatList = ReactNative.FlatList; 10 | global.Image = ReactNative.Image; 11 | global.ImageBackground = ReactNative.ImageBackground; 12 | global.KeyboardAvoidingView = ReactNative.KeyboardAvoidingView; 13 | global.Modal = ReactNative.Modal; 14 | global.RefreshControl = ReactNative.RefreshControl; 15 | global.SafeAreaView = ReactNative.SafeAreaView; 16 | global.ScrollView = ReactNative.ScrollView; 17 | global.SectionList = ReactNative.SectionList; 18 | global.StatusBar = ReactNative.StatusBar; 19 | global.StyleSheet = ReactNative.StyleSheet; 20 | global.Switch = ReactNative.Switch; 21 | global.Text = ReactNative.Text; 22 | global.TextInput = ReactNative.TextInput; 23 | global.TouchableHighlight = ReactNative.TouchableHighlight; 24 | global.TouchableNativeFeedback = ReactNative.TouchableNativeFeedback; 25 | global.TouchableOpacity = ReactNative.TouchableOpacity; 26 | global.TouchableWithoutFeedback = ReactNative.TouchableWithoutFeedback; 27 | global.View = ReactNative.View; 28 | global.VirtualizedList = ReactNative.VirtualizedList; 29 | 30 | // APIS 31 | global.AccessibilityInfo = ReactNative.AccessibilityInfo; 32 | global.Alert = ReactNative.Alert; 33 | global.Animated = ReactNative.Animated; 34 | global.AppRegistry = ReactNative.AppRegistry; 35 | global.AppState = ReactNative.AppState; 36 | global.BackHandler = ReactNative.BackHandler; 37 | global.DeviceEventEmitter = ReactNative.DeviceEventEmitter; 38 | global.Dimensions = ReactNative.Dimensions; 39 | global.Easing = ReactNative.Easing; 40 | global.InteractionManager = ReactNative.InteractionManager; 41 | global.Keyboard = ReactNative.Keyboard; 42 | global.LayoutAnimation = ReactNative.LayoutAnimation; 43 | global.Linking = ReactNative.Linking; 44 | global.NativeAppEventEmitter = ReactNative.NativeAppEventEmitter; 45 | global.NativeMethodsMixin = ReactNative.NativeMethodsMixin; 46 | global.NativeModules = ReactNative.NativeModules; 47 | global.PanResponder = ReactNative.PanResponder; 48 | global.PixelRatio = ReactNative.PixelRatio; 49 | global.Platform = ReactNative.Platform; 50 | global.Settings = ReactNative.Settings; 51 | global.Share = ReactNative.Share; 52 | global.StyleSheet = ReactNative.StyleSheet; 53 | global.Systrace = ReactNative.Systrace; 54 | global.Vibration = ReactNative.Vibration; 55 | 56 | //Device info 57 | global.DeviceHeight = Dimensions.get("window").height; 58 | global.DeviceWidth = Dimensions.get("window").width; 59 | 60 | --------------------------------------------------------------------------------