Skip to content

Commit

Permalink
[Exports] Expose more modules for authors of custom components
Browse files Browse the repository at this point in the history
Added some more exports to React that are either necessary or often useful for component authors.

I also exported React itself so that you can write just one destructuring assignment expression:
```
var {
  React,
  StyleSheet,
  View,
} = require('react-native');
```
  • Loading branch information
ide committed Apr 6, 2015
1 parent b360168 commit c7d9d3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Libraries/react-native/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
*/
'use strict';

var React = require('React');

// Export React, plus some native additions.
//
// The use of Object.create/assign is to work around a Flow bug (#6560135).
// Once that is fixed, change this back to
//
// var ReactNative = {...require('React'), /* additions */}
// var ReactNative = {...React, /* additions */}
//
var ReactNative = Object.assign(Object.create(require('React')), {
var ReactNative = Object.assign(Object.create(React), {
React,

// Components
ActivityIndicatorIOS: require('ActivityIndicatorIOS'),
DatePickerIOS: require('DatePickerIOS'),
Expand All @@ -29,6 +33,7 @@ var ReactNative = Object.assign(Object.create(require('React')), {
Navigator: require('Navigator'),
ScrollView: require('ScrollView'),
SliderIOS: require('SliderIOS'),
StaticContainer: require('StaticContainer.react'),
SwitchIOS: require('SwitchIOS'),
TabBarIOS: require('TabBarIOS'),
Text: require('Text'),
Expand Down Expand Up @@ -60,10 +65,15 @@ var ReactNative = Object.assign(Object.create(require('React')), {
DeviceEventEmitter: require('RCTDeviceEventEmitter'),
NativeModules: require('NativeModules'),

// Prop Types
EdgeInsetsPropType: require('EdgeInsetsPropType'),
PointPropType: require('PointPropType'),

addons: {
LinkedStateMixin: require('LinkedStateMixin'),
Perf: undefined,
PureRenderMixin: require('ReactComponentWithPureRenderMixin'),
StaticRenderer: require('StaticRenderer'),
TestModule: require('NativeModules').TestModule,
TestUtils: undefined,
batchedUpdates: require('ReactUpdates').batchedUpdates,
Expand Down

0 comments on commit c7d9d3b

Please sign in to comment.