diff --git a/docs/pushnotificationios.html b/docs/pushnotificationios.html deleted file mode 100644 index 60258e5e378..00000000000 --- a/docs/pushnotificationios.html +++ /dev/null @@ -1,11 +0,0 @@ -Error: ReferenceError: notification is not defined - at /Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/guard.js:27:12 - at onOutputGenerated (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/index.js:96:9) - at Object.renderReactPage.done (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/DefaultRouter.js:352:7) - at renderReactPage (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/renderReactPage.js:130:17) - at renderComponentPackage (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/DefaultRouter.js:338:3) - at routePackageHandler (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/DefaultRouter.js:281:5) - at onComputePackage (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/index.js:100:9) - at /Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/guard.js:29:10 - at onWarmed (/Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/src/Packager.js:270:9) - at /Users/travis/build/facebook/react-native/website/node_modules/react-page-middleware/node_modules/async/lib/async.js:116:25 \ No newline at end of file diff --git a/docs/scrollview.html b/docs/scrollview.html deleted file mode 100644 index 5f9a6a0a4c4..00000000000 --- a/docs/scrollview.html +++ /dev/null @@ -1,152 +0,0 @@ -React Native | A framework for building native apps using React

ScrollView

Component that wraps platform ScrollView while providing -integration with touch locking "responder" system.

Doesn't yet support other contained responders from blocking this scroll -view from becoming the responder.

Edit on GitHubProps #

alwaysBounceHorizontal bool #

When true, the scroll view bounces horizontally when it reaches the end -even if the content is smaller than the scroll view itself. The default -value is true when horizontal={true} and false otherwise.

alwaysBounceVertical bool #

When true, the scroll view bounces vertically when it reaches the end -even if the content is smaller than the scroll view itself. The default -value is false when horizontal={true} and true otherwise.

automaticallyAdjustContentInsets bool #

bounces bool #

When true, the scroll view bounces when it reaches the end of the -content if the content is larger then the scroll view along the axis of -the scroll direction. When false, it disables all bouncing even if -the alwaysBounce* props are true. The default value is true.

centerContent bool #

When true, the scroll view automatically centers the content when the -content is smaller than the scroll view bounds; when the content is -larger than the scroll view, this property has no effect. The default -value is false.

contentContainerStyle StyleSheetPropType(ViewStylePropTypes) #

These styles will be applied to the scroll view content container which -wraps all of the child views. Example:

return ( - <ScrollView contentContainerStyle={styles.contentContainer}> - </ScrollView> - ); - ... - var styles = StyleSheet.create({ - contentContainer: { - paddingVertical: 20 - } - });

contentInset {top: number, left: number, bottom: number, right: number} #

contentOffset PointPropType #

decelerationRate number #

A floating-point number that determines how quickly the scroll view -decelerates after the user lifts their finger. Reasonable choices include - - Normal: 0.998 (the default) - - Fast: 0.9

horizontal bool #

When true, the scroll view's children are arranged horizontally in a row -instead of vertically in a column. The default value is false.

keyboardDismissMode enum("none", 'interactive', 'onDrag') #

Determines whether the keyboard gets dismissed in response to a drag. - - 'none' (the default), drags do not dismiss the keyboard. - - 'onDrag', the keyboard is dismissed when a drag begins. - - 'interactive', the keyboard is dismissed interactively with the drag - and moves in synchrony with the touch; dragging upwards cancels the - dismissal.

keyboardShouldPersistTaps bool #

When false, tapping outside of the focused text input when the keyboard -is up dismisses the keyboard. When true, the scroll view will not catch -taps, and the keyboard will not dismiss automatically. The default value -is false.

maximumZoomScale number #

The maximum allowed zoom scale. The default value is 1.0.

minimumZoomScale number #

The minimum allowed zoom scale. The default value is 1.0.

onScroll function #

onScrollAnimationEnd function #

pagingEnabled bool #

When true, the scroll view stops on multiples of the scroll view's size -when scrolling. This can be used for horizontal pagination. The default -value is false.

removeClippedSubviews bool #

Experimental: When true, offscreen child views (whose overflow value is -hidden) are removed from their native backing superview when offscreen. -This canimprove scrolling performance on long lists. The default value is -false.

scrollEnabled bool #

scrollEventThrottle number #

scrollIndicatorInsets {top: number, left: number, bottom: number, right: number} #

scrollsToTop bool #

When true, the scroll view scrolls to top when the status bar is tapped. -The default value is true.

showsHorizontalScrollIndicator bool #

showsVerticalScrollIndicator bool #

stickyHeaderIndices [number] #

An array of child indices determining which children get docked to the -top of the screen when scrolling. For example, passing -stickyHeaderIndices={[0]} will cause the first child to be fixed to the -top of the scroll view. This property is not supported in conjunction -with horizontal={true}.

style style #

backgroundColor string
borderBottomColor string
borderColor string
borderLeftColor string
borderRadius number
borderRightColor string
borderTopColor string
opacity number
overflow enum('visible', 'hidden')
rotation number
scaleX number
scaleY number
shadowColor string
shadowOffset {h: number, w: number}
shadowOpacity number
shadowRadius number
transformMatrix [number]
translateX number
translateY number

zoomScale number #

The current scale of the scroll view content. The default value is 1.0.

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - ScrollView, - StyleSheet, - View, - Image -} = React; - -exports.title = '<ScrollView>'; -exports.description = 'Component that enables scrolling through child components'; -exports.examples = [ -{ - title: '<ScrollView>', - description: 'To make content scrollable, wrap it within a <ScrollView> component', - render: function() { - return ( - <ScrollView - onScroll={() => { console.log('onScroll!'); }} - scrollEventThrottle={200} - contentInset={{top: -50}} - style={styles.scrollView}> - {THUMBS.map(createThumbRow)} - </ScrollView> - ); - } -}, { - title: '<ScrollView> (horizontal = true)', - description: 'You can display <ScrollView>\'s child components horizontally rather than vertically', - render: function() { - return ( - <ScrollView - horizontal={true} - contentInset={{top: -50}} - style={[styles.scrollView, styles.horizontalScrollView]}> - {THUMBS.map(createThumbRow)} - </ScrollView> - ); - } -}]; - -var Thumb = React.createClass({ - shouldComponentUpdate: function(nextProps, nextState) { - return false; - }, - render: function() { - return ( - <View style={styles.button}> - <Image style={styles.img} source={{uri:this.props.uri}} /> - </View> - ); - } -}); - -var THUMBS = ['https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851549_767334479959628_274486868_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851579_767334503292959_179092627_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851589_767334513292958_1747022277_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851563_767334559959620_1193692107_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851593_767334566626286_1953955109_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851591_767334523292957_797560749_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851567_767334529959623_843148472_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851548_767334489959627_794462220_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851575_767334539959622_441598241_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851573_767334549959621_534583464_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851583_767334573292952_1519550680_n.png']; -THUMBS = THUMBS.concat(THUMBS); // double length of THUMBS -var createThumbRow = (uri, i) => <Thumb key={i} uri={uri} />; - -var styles = StyleSheet.create({ - scrollView: { - backgroundColor: '#6A85B1', - height: 300, - }, - horizontalScrollView: { - height: 120, - }, - containerPage: { - height: 50, - width: 50, - backgroundColor: '#527FE4', - padding: 5, - }, - text: { - fontSize: 20, - color: '#888888', - left: 80, - top: 20, - height: 40, - }, - button: { - margin: 7, - padding: 5, - alignItems: 'center', - backgroundColor: '#eaeaea', - borderRadius: 3, - }, - buttonContents: { - flexDirection: 'row', - width: 64, - height: 64, - }, - img: { - width: 64, - height: 64, - } -});
\ No newline at end of file diff --git a/docs/sliderios.html b/docs/sliderios.html deleted file mode 100644 index bf4ef6e92c5..00000000000 --- a/docs/sliderios.html +++ /dev/null @@ -1,69 +0,0 @@ -React Native | A framework for building native apps using React

SliderIOS

Edit on GitHubProps #

maximumValue number #

Initial maximum value of the slider. Default value is 1.

minimumValue number #

Initial minimum value of the slider. Default value is 0.

onSlidingComplete function #

Callback called when the user finishes changing the value (e.g. when -the slider is released).

onValueChange function #

Callback continuously called while the user is dragging the slider.

style View#style #

Used to style and layout the Slider. See StyleSheet.js and -ViewStylePropTypes.js for more info.

value number #

Initial value of the slider. The value should be between minimumValue -and maximumValue, which default to 0 and 1 respectively. -Default value is 0.

This is not a controlled component, e.g. if you don't update -the value, the component won't be reset to it's inital value.

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - SliderIOS, - Text, - StyleSheet, - View, -} = React; - -var SliderExample = React.createClass({ - getInitialState() { - return { - value: 0, - }; - }, - - render() { - return ( - <View> - <Text style={styles.text} > - {this.state.value} - </Text> - <SliderIOS - style={styles.slider} - onValueChange={(value) => this.setState({value: value})} /> - </View> - ); - } -}); - -var styles = StyleSheet.create({ - slider: { - height: 10, - margin: 10, - }, - text: { - fontSize: 14, - textAlign: 'center', - fontWeight: '500', - margin: 10, - }, -}); - -exports.title = '<SliderIOS>'; -exports.displayName = 'SliderExample'; -exports.description = 'Slider input for numeric values'; -exports.examples = [ - { - title: 'SliderIOS', - render(): ReactElement { return <SliderExample />; } - } -];
\ No newline at end of file diff --git a/docs/statusbarios.html b/docs/statusbarios.html deleted file mode 100644 index 5b92ef797b2..00000000000 --- a/docs/statusbarios.html +++ /dev/null @@ -1,95 +0,0 @@ -React Native | A framework for building native apps using React

StatusBarIOS

All rights reserved.

This source code is licensed under the BSD-style license found in the -LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory.

@flow

Methods #

static setStyle(style: number, animated?: boolean) #

static setHidden(hidden: boolean, animation: number) #

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - StyleSheet, - View, - Text, - TouchableHighlight, - StatusBarIOS, -} = React; - -exports.framework = 'React'; -exports.title = 'StatusBarIOS'; -exports.description = 'Module for controlling iOS status bar'; -exports.examples = [{ - title: 'Status Bar Style', - render() { - return ( - <View> - {Object.keys(StatusBarIOS.Style).map((key) => - <TouchableHighlight style={styles.wrapper} - onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key])}> - <View style={styles.button}> - <Text>setStyle(StatusBarIOS.Style.{key})</Text> - </View> - </TouchableHighlight> - )} - </View> - ); - }, -}, { - title: 'Status Bar Style Animated', - render() { - return ( - <View> - {Object.keys(StatusBarIOS.Style).map((key) => - <TouchableHighlight style={styles.wrapper} - onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key], true)}> - <View style={styles.button}> - <Text>setStyle(StatusBarIOS.Style.{key}, true)</Text> - </View> - </TouchableHighlight> - )} - </View> - ); - }, -}, { - title: 'Status Bar Hidden', - render() { - return ( - <View> - {Object.keys(StatusBarIOS.Animation).map((key) => - <View> - <TouchableHighlight style={styles.wrapper} - onPress={() => StatusBarIOS.setHidden(true, StatusBarIOS.Animation[key])}> - <View style={styles.button}> - <Text>setHidden(true, StatusBarIOS.Animation.{key})</Text> - </View> - </TouchableHighlight> - <TouchableHighlight style={styles.wrapper} - onPress={() => StatusBarIOS.setHidden(false, StatusBarIOS.Animation[key])}> - <View style={styles.button}> - <Text>setHidden(false, StatusBarIOS.Animation.{key})</Text> - </View> - </TouchableHighlight> - </View> - )} - </View> - ); - }, -}]; - -var styles = StyleSheet.create({ - wrapper: { - borderRadius: 5, - marginBottom: 5, - }, - button: { - backgroundColor: '#eeeeee', - padding: 10, - }, -});
\ No newline at end of file diff --git a/docs/style.html b/docs/style.html deleted file mode 100644 index b4e513299fe..00000000000 --- a/docs/style.html +++ /dev/null @@ -1,49 +0,0 @@ -React Native | A framework for building native apps using React

Style

React Native doesn't implement CSS but instead relies on JavaScript to let you style your application. This has been a controversial decision and you can read through those slides for the rationale behind it.

- -

Declare Styles #

The way to declare styles in React Native is the following:

var styles = StyleSheet.create({ - base: { - width: 38, - height: 38, - }, - background: { - backgroundColor: '#222222', - }, - active: { - borderWidth: 2, - borderColor: '#00ff00', - }, -});

StyleSheet.create construct is optional but provides some key advantages. It ensures that the values are immutable and opaque by transforming them into plain numbers that reference an internal table. By putting it at the end of the file, you also ensure that they are only created once for the application and not on every render.

All the attribute names and values are a subset of what works on the web. For layout, React Native implements Flexbox.

Using Styles #

All the core components accept a style attribute

<Text style={styles.base} /> -<View style={styles.background} />

and also accepts an array of styles

<View style={[styles.base, styles.background]} />

The behavior is the same as Object.assign: in case of conflicting values, the one from the right-most element will have precedence and falsy values like false, undefined and null will be ignored. A common pattern is to conditionally add a style based on some condition.

<View style={[styles.base, this.state.active && styles.active]} />

Finally, if you really have to, you can also create style objects in render, but they are highly discouraged. Put them last in the array definition.

<View - style={[styles.base, { - width: this.state.width, - height: this.state.width * this.state.aspectRatio - }]} -/>

Pass Styles Around #

In order to let a call site customize the style of your component children, you can pass styles around. Use View.propTypes.style and Text.propTypes.style in order to make sure only styles are being passed.

var List = React.createClass({ - propTypes: { - style: View.propTypes.style, - elementStyle: View.propTypes.style, - }, - render: function() { - return ( - <View style={this.props.style}> - {elements.map((element) => - <View style={[styles.element, this.props.elementStyle]} /> - )} - </View> - ); - } -}); - -// ... in another file ... -<List style={styles.list} elementStyle={styles.listElement} />

Supported Properties #

You can checkout latest support of CSS Properties in following Links.

\ No newline at end of file diff --git a/docs/stylesheet.html b/docs/stylesheet.html deleted file mode 100644 index 148f01164de..00000000000 --- a/docs/stylesheet.html +++ /dev/null @@ -1,31 +0,0 @@ -React Native | A framework for building native apps using React

StyleSheet

A StyleSheet is an abstraction similar to CSS StyleSheets

Create a new StyleSheet:

var styles = StyleSheet.create({ - container: { - borderRadius: 4, - borderWidth: 0.5, - borderColor: '#d6d7da', - }, - title: { - fontSize: 19, - fontWeight: 'bold', - }, - activeTitle: { - color: 'red', - }, -});

Use a StyleSheet:

<View style={styles.container}> - <Text style={[styles.title, this.props.isActive && styles.activeTitle]} /> -</View>

Code quality:

  • By moving styles away from the render function, you're making the code -code easier to understand.
  • Naming the styles is a good way to add meaning to the low level components -in the render function.

Performance:

  • Making a stylesheet from a style object makes it possible to refer to it -by ID instead of creating a new style object every time.
  • It also allows to send the style only once through the bridge. All -subsequent uses are going to refer an id (not implemented yet).

Methods #

static create(obj: {[key: string]: any}) #

\ No newline at end of file diff --git a/docs/switchios.html b/docs/switchios.html deleted file mode 100644 index 98d7f332a2e..00000000000 --- a/docs/switchios.html +++ /dev/null @@ -1,154 +0,0 @@ -React Native | A framework for building native apps using React

SwitchIOS

Use SwitchIOS to render a boolean input on iOS. This is -a controlled component, so you must hook in to the onValueChange callback -and update the value prop in order for the component to update, otherwise -the user's change will be reverted immediately to reflect props.value as the -source of truth.

Edit on GitHubProps #

disabled bool #

If true the user won't be able to toggle the switch. -Default value is false.

onTintColor string #

Background color when the switch is turned on.

onValueChange function #

Callback that is called when the user toggles the switch.

thumbTintColor string #

Background color for the switch round button.

tintColor string #

Background color when the switch is turned off.

value bool #

The value of the switch, if true the switch will be turned on. -Default value is false.

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - SwitchIOS, - Text, - View -} = React; - -var BasicSwitchExample = React.createClass({ - getInitialState() { - return { - trueSwitchIsOn: true, - falseSwitchIsOn: false, - }; - }, - render() { - return ( - <View> - <SwitchIOS - onValueChange={(value) => this.setState({falseSwitchIsOn: value})} - style={{marginBottom: 10}} - value={this.state.falseSwitchIsOn} /> - <SwitchIOS - onValueChange={(value) => this.setState({trueSwitchIsOn: value})} - value={this.state.trueSwitchIsOn} /> - </View> - ); - } -}); - -var DisabledSwitchExample = React.createClass({ - render() { - return ( - <View> - <SwitchIOS - disabled={true} - style={{marginBottom: 10}} - value={true} /> - <SwitchIOS - disabled={true} - value={false} /> - </View> - ); - }, -}); - -var ColorSwitchExample = React.createClass({ - getInitialState() { - return { - colorTrueSwitchIsOn: true, - colorFalseSwitchIsOn: false, - }; - }, - render() { - return ( - <View> - <SwitchIOS - onValueChange={(value) => this.setState({colorFalseSwitchIsOn: value})} - onTintColor="#00ff00" - style={{marginBottom: 10}} - thumbTintColor="#0000ff" - tintColor="#ff0000" - value={this.state.colorFalseSwitchIsOn} /> - <SwitchIOS - onValueChange={(value) => this.setState({colorTrueSwitchIsOn: value})} - onTintColor="#00ff00" - thumbTintColor="#0000ff" - tintColor="#ff0000" - value={this.state.colorTrueSwitchIsOn} /> - </View> - ); - }, -}); - -var EventSwitchExample = React.createClass({ - getInitialState() { - return { - eventSwitchIsOn: false, - eventSwitchRegressionIsOn: true, - }; - }, - render() { - return ( - <View style={{ flexDirection: 'row', justifyContent: 'space-around' }}> - <View> - <SwitchIOS - onValueChange={(value) => this.setState({eventSwitchIsOn: value})} - style={{marginBottom: 10}} - value={this.state.eventSwitchIsOn} /> - <SwitchIOS - onValueChange={(value) => this.setState({eventSwitchIsOn: value})} - style={{marginBottom: 10}} - value={this.state.eventSwitchIsOn} /> - <Text>{this.state.eventSwitchIsOn ? "On" : "Off"}</Text> - </View> - <View> - <SwitchIOS - onValueChange={(value) => this.setState({eventSwitchRegressionIsOn: value})} - style={{marginBottom: 10}} - value={this.state.eventSwitchRegressionIsOn} /> - <SwitchIOS - onValueChange={(value) => this.setState({eventSwitchRegressionIsOn: value})} - style={{marginBottom: 10}} - value={this.state.eventSwitchRegressionIsOn} /> - <Text>{this.state.eventSwitchRegressionIsOn ? "On" : "Off"}</Text> - </View> - </View> - ); - } -}); - -exports.title = '<SwitchIOS>'; -exports.displayName = 'SwitchExample'; -exports.description = 'Native boolean input'; -exports.examples = [ - { - title: 'Switches can be set to true or false', - render(): ReactElement { return <BasicSwitchExample />; } - }, - { - title: 'Switches can be disabled', - render(): ReactElement { return <DisabledSwitchExample />; } - }, - { - title: 'Custom colors can be provided', - render(): ReactElement { return <ColorSwitchExample />; } - }, - { - title: 'Change events can be detected', - render(): ReactElement { return <EventSwitchExample />; } - }, - { - title: 'Switches are controlled components', - render(): ReactElement { return <SwitchIOS />; } - } -];
\ No newline at end of file diff --git a/docs/tabbarios.html b/docs/tabbarios.html deleted file mode 100644 index 2929eaaabc4..00000000000 --- a/docs/tabbarios.html +++ /dev/null @@ -1,116 +0,0 @@ -React Native | A framework for building native apps using React

TabBarIOS

Edit on GitHubProps #

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - StyleSheet, - TabBarIOS, - Text, - View, -} = React; -var TabBarItemIOS = TabBarIOS.Item; -var TabBarExample = React.createClass({ - - statics: { - title: '<TabBarIOS>', - description: 'Tab-based navigation.' - }, - - getInitialState: function() { - return { - selectedTab: 'redTab', - notifCount: 0, - presses: 0, - }; - }, - - _renderContent: function(color: string, pageText: string) { - return ( - <View style={[styles.tabContent, {backgroundColor: color}]}> - <Text style={styles.tabText}>{pageText}</Text> - <Text style={styles.tabText}>{this.state.presses} re-renders of this tab</Text> - </View> - ); - }, - - render: function() { - return ( - <TabBarIOS - selectedTab={this.state.selectedTab}> - <TabBarItemIOS - name="blueTab" - icon={_ix_DEPRECATED('favorites')} - accessibilityLabel="Blue Tab" - selected={this.state.selectedTab === 'blueTab'} - onPress={() => { - this.setState({ - selectedTab: 'blueTab', - }); - }}> - {this._renderContent('#414A8C', 'Blue Tab')} - </TabBarItemIOS> - <TabBarItemIOS - accessibilityLabel="Red Tab" - name="redTab" - icon={_ix_DEPRECATED('history')} - badgeValue={this.state.notifCount ? String(this.state.notifCount) : null} - selected={this.state.selectedTab === 'redTab'} - onPress={() => { - this.setState({ - selectedTab: 'redTab', - notifCount: this.state.notifCount + 1, - }); - }}> - {this._renderContent('#783E33', 'Red Tab')} - </TabBarItemIOS> - <TabBarItemIOS - name="greenTab" - icon={_ix_DEPRECATED('more')} - accessibilityLabel="Green Tab" - selected={this.state.selectedTab === 'greenTab'} - onPress={() => { - this.setState({ - selectedTab: 'greenTab', - presses: this.state.presses + 1 - }); - }}> - {this._renderContent('#21551C', 'Green Tab')} - </TabBarItemIOS> - </TabBarIOS> - ); - }, - -}); - -var styles = StyleSheet.create({ - tabContent: { - flex: 1, - alignItems: 'center', - }, - tabText: { - color: 'white', - margin: 50, - }, -}); - -// This is needed because the actual image may not exist as a file and -// is used by the native code to load a system image. -// TODO(nicklockwood): How can this fit our require system? -function _ix_DEPRECATED(imageUri) { - return { - uri: imageUri, - isStatic: true, - }; -} - -module.exports = TabBarExample;
\ No newline at end of file diff --git a/docs/testing.html b/docs/testing.html deleted file mode 100644 index ee340d20937..00000000000 --- a/docs/testing.html +++ /dev/null @@ -1,12 +0,0 @@ -React Native | A framework for building native apps using React

Testing

Running Tests and Contributing #

The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the Travis continuous integration system, and will automatically post the results to your PR. You can also run them locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode. You can run the jest tests via npm test on the command line. We don't have great test coverage yet, however, so most changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage!

Jest Tests #

Jest tests are JS-only tests run on the command line with node. The tests themselves live in the __tests__ directories of the files they test, and there is a large emphasis on aggressively mocking out functionality that is not under test for failure isolation and maximum speed. You can run the existing React Native jest tests with npm test from the react-native root, and we encourage you to add your own tests for any components you want to contribute to. See getImageSource-test.js for a basic example.

Integration Tests. #

React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are RCTTestRunner and RCTTestModule. RCTTestRunner sets up the ReactNative environment and provides facilities to run the tests as XCTestCases in Xcode (runTest:module is the simplest method). RCTTestModule is exported to JS via NativeModules as TestModule. The tests themselves are written in JS, and must call TestModule.markTestCompleted() when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing an exception. It is also possible to test error conditions with runTest:module:initialProps:expectErrorRegex: or runTest:module:initialProps:expectErrorBlock: which will expect an error to be thrown and verify the error matches the provided criteria. See IntegrationTestHarnessTest.js and IntegrationTestsTests.m for example usage.

Snapshot Tests #

A common type of integration test is the snapshot test. These tests render a component, and verify snapshots of the screen against reference images using TestModule.verifySnapshot(), using the FBSnapshotTestCase library behind the scenes. Reference images are recorded by setting recordMode = YES on the RCTTestRunner, then running the tests. Snapshots will differ slightly between 32 and 64 bit, and various OS versions, so it's recommended that you enforce tests are run with the correct configuration. It's also highly recommended that all network data be mocked out, along with other potentially troublesome dependencies. See SimpleSnapshotTest for a basic example.

\ No newline at end of file diff --git a/docs/text.html b/docs/text.html deleted file mode 100644 index 8ba91e58699..00000000000 --- a/docs/text.html +++ /dev/null @@ -1,399 +0,0 @@ -React Native | A framework for building native apps using React

Text

A react component for displaying text which supports nesting, -styling, and touch handling. In the following example, the nested title and -body text will inherit the fontFamily from styles.baseText, but the title -provides its own additional styles. The title and body will stack on top of -each other on account of the literal newlines:

renderText: function() { - return ( - <Text style={styles.baseText}> - <Text style={styles.titleText} onPress={this.onPressTitle}> - {this.state.titleText + '\n\n'} - </Text> - <Text numberOfLines={5}> - {this.state.bodyText} - </Text> - </Text> - ); -}, -... -var styles = StyleSheet.create({ - baseText: { - fontFamily: 'Cochin', - }, - titleText: { - fontSize: 20, - fontWeight: 'bold', - }, -};

Edit on GitHubProps #

numberOfLines number #

Used to truncate the text with an elipsis after computing the text -layout, including line wrapping, such that the total number of lines does -not exceed this number.

onPress function #

This function is called on press. Text intrinsically supports press -handling with a default highlight state (which can be disabled with -suppressHighlighting).

style style #

color string
containerBackgroundColor string
fontFamily string
fontSize number
fontStyle enum('normal', 'italic')
fontWeight enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')
lineHeight number
textAlign enum("auto", 'left', 'right', 'center')
writingDirection enum("auto", 'ltr', 'rtl')

suppressHighlighting bool #

When true, no visual change is made when text is pressed down. By -default, a gray oval highlights the text on press down.

testID string #

Used to locate this view in end-to-end tests.

Edit on GitHubDescription #

Nested Text #

In iOS, the way to display formatted text is by using NSAttributedString: you give the text that you want to display and annotate ranges with some specific formatting. In practice, this is very tedious. For React Native, we decided to use web paradigm for this where you can nest text to achieve the same effect.

<Text style={{fontWeight: 'bold'}}> - I am bold - <Text style={{color: 'red'}}> - and red - </Text> -</Text>

Behind the scenes, this is going to be converted to a flat NSAttributedString that contains the following information

"I am bold and red" -0-9: bold -9-17: bold, red

Containers #

The <Text> element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a <Text> are no longer rectangles, but wrap when they see the end of the line.

<Text> - <Text>First part and </Text> - <Text>second part</Text> -</Text> -// Text container: all the text flows as if it was one -// |First part | -// |and second | -// |part | - -<View> - <Text>First part and </Text> - <Text>second part</Text> -</View> -// View container: each text is its own block -// |First part | -// |and | -// |second part|

Limited Style Inheritance #

On the web, the usual way to set a font family and size for the entire document is to write:

/* CSS, *not* React Native */ -html { - font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; - font-size: 11px; - color: #141823; -}

When the browser is trying to render a text node, it's going to go all the way up to the root element of the tree and find an element with a font-size attribute. An unexpected property of this system is that any node can have font-size attribute, including a <div>. This was designed for convenience, even though not really semantically correct.

In React Native, we are more strict about it: you must wrap all the text nodes inside of a <Text> component; you cannot have a text node directly under a <View>.

// BAD: will fatal, can't have a text node as child of a <View> -<View> - Some text -</View> - -// GOOD -<View> - <Text> - Some text - </Text> -</View>

You also lose the ability to set up a default font for an entire subtree. The recommended way to use consistent fonts and sizes across your application is to create a component MyAppText that includes them and use this component across your app. You can also use this component to make more specific components like MyAppHeaderText for other kinds of text.

<View> - <MyAppText>Text styled with the default font for the entire application</MyAppText> - <MyAppHeaderText>Text styled as a header</MyAppHeaderText> -</View>

React Native still has the concept of style inheritance, but limited to text subtrees. In this case, the second part will be both bold and red.

<Text style={{fontWeight: 'bold'}}> - I am bold - <Text style={{color: 'red'}}> - and red - </Text> -</Text>

We believe that this more constrained way to style text will yield better apps:

  • (Developer) React components are designed with strong isolation in mind: You should be able to drop a component anywhere in your application, trusting that as long as the props are the same, it will look and behave the same way. Text properties that could inherit from outside of the props would break this isolation.

  • (Implementor) The implementation of React Native is also simplified. We do not need to have a fontFamily field on every single element, and we do not need to potentially traverse the tree up to the root every time we display a text node. The style inheritance is only encoded inside of the native Text component and doesn't leak to other components or the system itself.

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - StyleSheet, - Text, - View, -} = React; - -var Entity = React.createClass({ - render: function() { - return ( - <Text style={styles.entity}> - {this.props.children} - </Text> - ); - } -}); - -var AttributeToggler = React.createClass({ - getInitialState: function() { - return {fontWeight: '500', fontSize: 15}; - }, - increaseSize: function() { - this.setState({ - fontSize: this.state.fontSize + 1 - }); - }, - render: function() { - var curStyle = {fontSize: this.state.fontSize}; - return ( - <Text> - <Text style={curStyle}> - Tap the controls below to change attributes. - </Text> - <Text> - See how it will even work on{' '} - <Text style={curStyle}> - this nested text - </Text> - <Text onPress={this.increaseSize}> - {'>> Increase Size <<'} - </Text> - </Text> - </Text> - ); - } -}); - -exports.title = '<Text>'; -exports.description = 'Base component for rendering styled text.'; -exports.displayName = 'TextExample'; -exports.examples = [ -{ - title: 'Wrap', - render: function() { - return ( - <Text> - The text should wrap if it goes on multiple lines. See, this is going to - the next line. - </Text> - ); - }, -}, { - title: 'Padding', - render: function() { - return ( - <Text style={{padding: 10}}> - This text is indented by 10px padding on all sides. - </Text> - ); - }, -}, { - title: 'Font Family', - render: function() { - return ( - <View> - <Text style={{fontFamily: 'Cochin'}}> - Cochin - </Text> - <Text style={{fontFamily: 'Cochin', fontWeight: 'bold'}}> - Cochin bold - </Text> - <Text style={{fontFamily: 'Helvetica'}}> - Helvetica - </Text> - <Text style={{fontFamily: 'Helvetica', fontWeight: 'bold'}}> - Helvetica bold - </Text> - <Text style={{fontFamily: 'Verdana'}}> - Verdana - </Text> - <Text style={{fontFamily: 'Verdana', fontWeight: 'bold'}}> - Verdana bold - </Text> - </View> - ); - }, -}, { - title: 'Font Size', - render: function() { - return ( - <View> - <Text style={{fontSize: 23}}> - Size 23 - </Text> - <Text style={{fontSize: 8}}> - Size 8 - </Text> - </View> - ); - }, -}, { - title: 'Color', - render: function() { - return ( - <View> - <Text style={{color: 'red'}}> - Red color - </Text> - <Text style={{color: 'blue'}}> - Blue color - </Text> - </View> - ); - }, -}, { - title: 'Font Weight', - render: function() { - return ( - <View> - <Text style={{fontWeight: '100'}}> - Move fast and be ultralight - </Text> - <Text style={{fontWeight: '200'}}> - Move fast and be light - </Text> - <Text style={{fontWeight: 'normal'}}> - Move fast and be normal - </Text> - <Text style={{fontWeight: 'bold'}}> - Move fast and be bold - </Text> - <Text style={{fontWeight: '900'}}> - Move fast and be ultrabold - </Text> - </View> - ); - }, -}, { - title: 'Font Style', - render: function() { - return ( - <View> - <Text style={{fontStyle: 'normal'}}> - Normal text - </Text> - <Text style={{fontStyle: 'italic'}}> - Italic text - </Text> - </View> - ); - }, -}, { - title: 'Nested', - description: 'Nested text components will inherit the styles of their ' + - 'parents (only backgroundColor is inherited from non-Text parents). ' + - '<Text> only supports other <Text> and raw text (strings) as children.', - render: function() { - return ( - <View> - <Text> - (Normal text, - <Text style={{fontWeight: 'bold'}}> - (and bold - <Text style={{fontSize: 11, color: '#527fe4'}}> - (and tiny inherited bold blue) - </Text> - ) - </Text> - ) - </Text> - <Text style={{fontSize: 12}}> - <Entity>Entity Name</Entity> - </Text> - </View> - ); - }, -}, { - title: 'Text Align', - render: function() { - return ( - <View> - <Text style={{textAlign: 'left'}}> - left left left left left left left left left left left left left left left - </Text> - <Text style={{textAlign: 'center'}}> - center center center center center center center center center center center - </Text> - <Text style={{textAlign: 'right'}}> - right right right right right right right right right right right right right - </Text> - </View> - ); - }, -}, { - title: 'Spaces', - render: function() { - return ( - <Text> - A {'generated'} {' '} {'string'} and some &nbsp;&nbsp;&nbsp; spaces - </Text> - ); - }, -}, { - title: 'Line Height', - render: function() { - return ( - <Text> - <Text style={{lineHeight: 35}}> - A lot of space between the lines of this long passage that should - wrap once. - </Text> - </Text> - ); - }, -}, { - title: 'Empty Text', - description: 'It\'s ok to have Text with zero or null children.', - render: function() { - return ( - <Text /> - ); - }, -}, { - title: 'Toggling Attributes', - render: function(): ReactElement { - return <AttributeToggler />; - }, -}, { - title: 'backgroundColor attribute', - description: 'backgroundColor is inherited from all types of views.', - render: function() { - return ( - <View style={{backgroundColor: 'yellow'}}> - <Text> - Yellow background inherited from View parent, - <Text style={{backgroundColor: '#ffaaaa'}}> - {' '}red background, - <Text style={{backgroundColor: '#aaaaff'}}> - {' '}blue background, - <Text> - {' '}inherited blue background, - <Text style={{backgroundColor: '#aaffaa'}}> - {' '}nested green background. - </Text> - </Text> - </Text> - </Text> - </Text> - </View> - ); - }, -}, { - title: 'containerBackgroundColor attribute', - render: function() { - return ( - <View> - <View style={{flexDirection: 'row', height: 85}}> - <View style={{backgroundColor: '#ffaaaa', width: 150}} /> - <View style={{backgroundColor: '#aaaaff', width: 150}} /> - </View> - <Text style={[styles.backgroundColorText, {top: -80}]}> - Default containerBackgroundColor (inherited) + backgroundColor wash - </Text> - <Text style={[ - styles.backgroundColorText, - {top: -70, containerBackgroundColor: 'transparent'}]}> - {"containerBackgroundColor: 'transparent' + backgroundColor wash"} - </Text> - </View> - ); - }, -}, { - title: 'numberOfLines attribute', - render: function() { - return ( - <View> - <Text numberOfLines={1}> - Maximum of one line no matter now much I write here. If I keep writing it{"'"}ll just truncate after one line - </Text> - <Text numberOfLines={2} style={{marginTop: 20}}> - Maximum of two lines no matter now much I write here. If I keep writing it{"'"}ll just truncate after two lines - </Text> - <Text style={{marginTop: 20}}> - No maximum lines specified no matter now much I write here. If I keep writing it{"'"}ll just keep going and going - </Text> - </View> - ); - }, -}]; - -var styles = StyleSheet.create({ - backgroundColorText: { - left: 5, - backgroundColor: 'rgba(100, 100, 100, 0.3)' - }, - entity: { - fontWeight: '500', - color: '#527fe4', - }, -});
\ No newline at end of file diff --git a/docs/textinput.html b/docs/textinput.html deleted file mode 100644 index 8b781e73233..00000000000 --- a/docs/textinput.html +++ /dev/null @@ -1,337 +0,0 @@ -React Native | A framework for building native apps using React

TextInput

A foundational component for inputting text into the app via a -keyboard. Props provide configurability for several features, such as auto- -correction, auto-capitalization, placeholder text, and different keyboard -types, such as a numeric keypad.

The simplest use case is to plop down a TextInput and subscribe to the -onChangeText events to read the user input. There are also other events, such -as onSubmitEditing and onFocus that can be subscribed to. A simple -example:

<View> - <TextInput - style={{height: 40, borderColor: 'gray', borderWidth: 1}} - onChangeText={(text) => this.setState({input: text})} - /> - <Text>{'user input: ' + this.state.input}</Text> -</View>

The value prop can be used to set the value of the input in order to make -the state of the component clear, but <TextInput> does not behave as a true -controlled component by default because all operations are asynchronous. -Setting value once is like setting the default value, but you can change it -continuously based on onChangeText events as well. If you really want to -force the component to always revert to the value you are setting, you can -set controlled={true}.

The multiline prop is not supported in all releases, and some props are -multiline only.

Edit on GitHubProps #

autoCapitalize enum('none', 'sentences', 'words', 'characters') #

Can tell TextInput to automatically capitalize certain characters.

  • characters: all characters,
  • words: first letter of each word
  • sentences: first letter of each sentence (default)
  • none: don't auto capitalize anything

autoCorrect bool #

If false, disables auto-correct. Default value is true.

autoFocus bool #

If true, focuses the input on componentDidMount. Default value is false.

bufferDelay number #

This helps avoid drops characters due to race conditions between JS and -the native text input. The default should be fine, but if you're -potentially doing very slow operations on every keystroke then you may -want to try increasing this.

clearButtonMode enum('never', 'while-editing', 'unless-editing', 'always') #

When the clear button should appear on the right side of the text view

controlled bool #

If you really want this to behave as a controlled component, you can set -this true, but you will probably see flickering, dropped keystrokes, -and/or laggy typing, depending on how you process onChange events.

editable bool #

If false, text is not editable. Default value is true.

enablesReturnKeyAutomatically bool #

If true, the keyboard disables the return key when there is no text and -automatically enables it when there is text. Default value is false.

keyboardType enum('default', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', 'email-address', 'decimal-pad', 'twitter', 'web-search', "numeric") #

Determines which keyboard to open, e.g.numeric.

multiline bool #

If true, the text input can be multiple lines. Default value is false.

onBlur function #

Callback that is called when the text input is blurred

onChange function #

(text: string) => void

Callback that is called when the text input's text changes.

onChangeText function #

onEndEditing function #

onFocus function #

Callback that is called when the text input is focused

onSubmitEditing function #

password bool #

If true, the TextInput will be a password field. Default value is false.

placeholder string #

The string that will be rendered before text input has been entered

placeholderTextColor string #

The text color of the placeholder string

returnKeyType enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call') #

Determines how the return key should look.

secureTextEntry bool #

If true, the text input obscures the text entered so that sensitive text -like passwords stay secure. Default value is false.

selectionState DocumentSelectionState #

See DocumentSelectionState.js, some state that is responsible for -maintaining selection information for a document

testID string #

Used to locate this view in end-to-end tests.

value string #

The default value for the text input

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - Text, - TextInput, - View, - StyleSheet, -} = React; - -var WithLabel = React.createClass({ - render: function() { - return ( - <View style={styles.labelContainer}> - <View style={styles.label}> - <Text>{this.props.label}</Text> - </View> - {this.props.children} - </View> - ); - } -}); - -var TextEventsExample = React.createClass({ - getInitialState: function() { - return { - curText: '<No Event>', - prevText: '<No Event>', - }; - }, - - updateText: function(text) { - this.setState({ - curText: text, - prevText: this.state.curText, - }); - }, - - render: function() { - return ( - <View> - <TextInput - autoCapitalize="none" - placeholder="Enter text to see events" - autoCorrect={false} - onFocus={() => this.updateText('onFocus')} - onBlur={() => this.updateText('onBlur')} - onChange={(event) => this.updateText( - 'onChange text: ' + event.nativeEvent.text - )} - onEndEditing={(event) => this.updateText( - 'onEndEditing text: ' + event.nativeEvent.text - )} - onSubmitEditing={(event) => this.updateText( - 'onSubmitEditing text: ' + event.nativeEvent.text - )} - style={styles.default} - /> - <Text style={styles.eventLabel}> - {this.state.curText}{'\n'} - (prev: {this.state.prevText}) - </Text> - </View> - ); - } -}); - -var styles = StyleSheet.create({ - page: { - paddingBottom: 300, - }, - default: { - height: 26, - borderWidth: 0.5, - borderColor: '#0f0f0f', - padding: 4, - flex: 1, - fontSize: 13, - }, - multiline: { - borderWidth: 0.5, - borderColor: '#0f0f0f', - flex: 1, - fontSize: 13, - height: 50, - }, - eventLabel: { - margin: 3, - fontSize: 12, - }, - labelContainer: { - flexDirection: 'row', - marginVertical: 2, - flex: 1, - }, - label: { - width: 80, - justifyContent: 'flex-end', - flexDirection: 'row', - marginRight: 10, - paddingTop: 2, - }, -}); - -exports.title = '<TextInput>'; -exports.description = 'Single-line text inputs.'; -exports.examples = [ - { - title: 'Auto-focus', - render: function() { - return <TextInput autoFocus={true} style={styles.default} />; - } - }, - { - title: 'Auto-capitalize', - render: function() { - return ( - <View> - <WithLabel label="none"> - <TextInput - autoCapitalize="none" - style={styles.default} - /> - </WithLabel> - <WithLabel label="sentences"> - <TextInput - autoCapitalize="sentences" - style={styles.default} - /> - </WithLabel> - <WithLabel label="words"> - <TextInput - autoCapitalize="words" - style={styles.default} - /> - </WithLabel> - <WithLabel label="characters"> - <TextInput - autoCapitalize="characters" - style={styles.default} - /> - </WithLabel> - </View> - ); - } - }, - { - title: 'Auto-correct', - render: function() { - return ( - <View> - <WithLabel label="true"> - <TextInput autoCorrect={true} style={styles.default} /> - </WithLabel> - <WithLabel label="false"> - <TextInput autoCorrect={false} style={styles.default} /> - </WithLabel> - </View> - ); - } - }, - { - title: 'Keyboard types', - render: function() { - var keyboardTypes = [ - 'default', - 'ascii-capable', - 'numbers-and-punctuation', - 'url', - 'number-pad', - 'phone-pad', - 'name-phone-pad', - 'email-address', - 'decimal-pad', - 'twitter', - 'web-search', - 'numeric', - ]; - var examples = keyboardTypes.map((type) => { - return ( - <WithLabel key={type} label={type}> - <TextInput - keyboardType={type} - style={styles.default} - /> - </WithLabel> - ); - }); - return <View>{examples}</View>; - } - }, - { - title: 'Return key types', - render: function() { - var returnKeyTypes = [ - 'default', - 'go', - 'google', - 'join', - 'next', - 'route', - 'search', - 'send', - 'yahoo', - 'done', - 'emergency-call', - ]; - var examples = returnKeyTypes.map((type) => { - return ( - <WithLabel key={type} label={type}> - <TextInput - returnKeyType={type} - style={styles.default} - /> - </WithLabel> - ); - }); - return <View>{examples}</View>; - } - }, - { - title: 'Enable return key automatically', - render: function() { - return ( - <View> - <WithLabel label="true"> - <TextInput enablesReturnKeyAutomatically={true} style={styles.default} /> - </WithLabel> - </View> - ); - } - }, - { - title: 'Secure text entry', - render: function() { - return ( - <View> - <WithLabel label="true"> - <TextInput secureTextEntry={true} style={styles.default} value="abc" /> - </WithLabel> - </View> - ); - } - }, - { - title: 'Event handling', - render: function(): ReactElement { return <TextEventsExample /> }, - }, - { - title: 'Colored input text', - render: function() { - return ( - <View> - <TextInput - style={[styles.default, {color: 'blue'}]} - value="Blue" - /> - <TextInput - style={[styles.default, {color: 'green'}]} - value="Green" - /> - </View> - ); - } - }, - { - title: 'Clear button mode', - render: function () { - return ( - <View> - <WithLabel label="never"> - <TextInput - style={styles.default} - clearButtonMode="never" - /> - </WithLabel> - <WithLabel label="while editing"> - <TextInput - style={styles.default} - clearButtonMode="while-editing" - /> - </WithLabel> - <WithLabel label="unless editing"> - <TextInput - style={styles.default} - clearButtonMode="unless-editing" - /> - </WithLabel> - <WithLabel label="always"> - <TextInput - style={styles.default} - clearButtonMode="always" - /> - </WithLabel> - </View> - ); - } - }, -];
\ No newline at end of file diff --git a/docs/timers.html b/docs/timers.html deleted file mode 100644 index 3062dd81df7..00000000000 --- a/docs/timers.html +++ /dev/null @@ -1,28 +0,0 @@ -React Native | A framework for building native apps using React

Timers

Timers are an important part of an application and React Native implements the browser timers.

Timers #

  • setTimeout, clearTimeout
  • setInterval, clearInterval
  • setImmediate, clearImmediate
  • requestAnimationFrame, cancelAnimationFrame

requestAnimationFrame(fn) is the exact equivalent of setTimeout(fn, 0), they are triggered right after the screen has been flushed.

setImmediate is executed at the end of the current JavaScript execution block, right before sending the batched response back to native. Note that if you call setImmediate within a setImmediate callback, it will be executed right away, it won't yield back to native in between.

The Promise implementation uses setImmediate as its asynchronicity primitive.

InteractionManager #

One reason why well-built native apps feel so smooth is by avoiding expensive operations during interactions and animations. In React Native, we currently have a limitation that there is only a single JS execution thread, but you can use InteractionManager to make sure long-running work is scheduled to start after any interactions/animations have completed.

Applications can schedule tasks to run after interactions with the following:

InteractionManager.runAfterInteractions(() => { - // ...long-running synchronous task... -});

Compare this to other scheduling alternatives:

  • requestAnimationFrame(): for code that animates a view over time.
  • setImmediate/setTimeout/setInterval(): run code later, note this may delay animations.
  • runAfterInteractions(): run code later, without delaying active animations.

The touch handling system considers one or more active touches to be an 'interaction' and will delay runAfterInteractions() callbacks until all touches have ended or been cancelled.

InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

var handle = InteractionManager.createInteractionHandle(); -// run animation... (`runAfterInteractions` tasks are queued) -// later, on animation completion: -InteractionManager.clearInteractionHandle(handle); -// queued tasks run if all handles were cleared

TimerMixin #

We found out that the primary cause of fatals in apps created with React Native was due to timers firing after a component was unmounted. To solve this recurring issue, we introduced TimerMixin. If you include TimerMixin, then you can replace your calls to setTimeout(fn, 500) with this.setTimeout(fn, 500) (just prepend this.) and everything will be properly cleaned up for you when the component unmounts.

var TimerMixin = require('react-timer-mixin'); - -var Component = React.createClass({ - mixins: [TimerMixin], - componentDidMount: function() { - this.setTimeout( - () => { console.log('I do not leak!'); }, - 500 - ); - } -});

We highly recommend never using bare timers and always using this mixin, it will save you from a lot of hard to track down bugs.

\ No newline at end of file diff --git a/docs/touchablehighlight.html b/docs/touchablehighlight.html deleted file mode 100644 index 188b5e4c8ca..00000000000 --- a/docs/touchablehighlight.html +++ /dev/null @@ -1,28 +0,0 @@ -React Native | A framework for building native apps using React

TouchableHighlight

A wrapper for making views respond properly to touches. -On press down, the opacity of the wrapped view is decreased, which allows -the underlay color to show through, darkening or tinting the view. The -underlay comes from adding a view to the view hierarchy, which can sometimes -cause unwanted visual artifacts if not used correctly, for example if the -backgroundColor of the wrapped view isn't explicitly set to an opaque color.

Example:

renderButton: function() { - return ( - <TouchableHighlight onPress={this._onPressButton}> - <Image - style={styles.button} - source={require('image!myButton')} - /> - </TouchableHighlight> - ); -},

Edit on GitHubProps #

activeOpacity number #

Determines what the opacity of the wrapped view should be when touch is -active.

underlayColor string #

The color of the underlay that will show through when the touch is -active.

\ No newline at end of file diff --git a/docs/touchableopacity.html b/docs/touchableopacity.html deleted file mode 100644 index a1488f131e6..00000000000 --- a/docs/touchableopacity.html +++ /dev/null @@ -1,25 +0,0 @@ -React Native | A framework for building native apps using React

TouchableOpacity

A wrapper for making views respond properly to touches. -On press down, the opacity of the wrapped view is decreased, dimming it. -This is done without actually changing the view hierarchy, and in general is -easy to add to an app without weird side-effects.

Example:

renderButton: function() { - return ( - <TouchableOpacity onPress={this._onPressButton}> - <Image - style={styles.button} - source={require('image!myButton')} - /> - </TouchableOpacity> - ); -},

Edit on GitHubProps #

activeOpacity number #

Determines what the opacity of the wrapped view should be when touch is -active.

\ No newline at end of file diff --git a/docs/touchablewithoutfeedback.html b/docs/touchablewithoutfeedback.html deleted file mode 100644 index a2fb51d6c11..00000000000 --- a/docs/touchablewithoutfeedback.html +++ /dev/null @@ -1,15 +0,0 @@ -React Native | A framework for building native apps using React

TouchableWithoutFeedback

Do not use unless you have a very good reason. All the elements that -respond to press should have a visual feedback when touched. This is -one of the primary reason a "web" app doesn't feel "native".

Edit on GitHubProps #

onLongPress function #

onPress function #

Called when the touch is released, but not if cancelled (e.g. by a scroll -that steals the responder lock).

onPressIn function #

onPressOut function #

\ No newline at end of file diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html deleted file mode 100644 index fe51829719e..00000000000 --- a/docs/troubleshooting.html +++ /dev/null @@ -1,20 +0,0 @@ -React Native | A framework for building native apps using React

Troubleshooting

Cmd-R does not reload the simulator #

Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.

Keyboard Menu

If you are using a non-QWERTY/AZERTY keyboard layout you can use the Hardware > Shake Gesture to bring up the dev menu and click "Refresh"

Port already in use red-screen #

red-screen

Something is probably already running on port 8081. You can either kill it or try to change which port the packager is listening to.

Kill process on port 8081 #

$ sudo lsof -n -i4TCP:8081 | grep LISTEN

then

$ kill -9 <cma process id>

Change the port in Xcode #

Edit AppDelegate.m to use a different port.

// OPTION 1 - // Load from development server. Start the server from the repository root: - // - // $ npm start - // - // To run on device, change `localhost` to the IP address of your computer, and make sure your computer and - // iOS device are on the same Wi-Fi network. - jsCodeLocation = [NSURL URLWithString:@"http://localhost:9381/index.ios.bundle"];

Watchman took too long to load #

Permission settings prevent Wathcman to load. A recent update solves this, get a HEAD install of Watchman if you are experiening this error.

brew uninstall watchman -brew install --HEAD watchman
\ No newline at end of file diff --git a/docs/tutorial.html b/docs/tutorial.html deleted file mode 100644 index 006d41bc1fd..00000000000 --- a/docs/tutorial.html +++ /dev/null @@ -1,299 +0,0 @@ -React Native | A framework for building native apps using React

Tutorial

Preface #

This tutorial aims to get you up to speed with writing iOS apps using React Native. If you're wondering what React Native is and why Facebook built it, this blog post explains that.

We assume you have experience writing websites with React. If not, you can learn about it on the React website.

Setup #

React Native requires OSX, Xcode, Homebrew, node, npm, and watchman. Flow is optional.

After installing these dependencies there are two simple commands to get a React Native project all set up for development.

  1. npm install -g react-native-cli

    react-native-cli is a command line interface that does the rest of the set up. It’s installable via npm. This will install react-nativeas a command in your terminal. You only ever need to do this once.

  2. react-native init AwesomeProject

    This command fetches the React Native source code and dependencies and then creates a new Xcode project in AwesomeProject/AwesomeProject.xcodeproj.

Development #

You can now open this new project (AwesomeProject/AwesomeProject.xcodeproj) in Xcode and simply build and run it with cmd+R. Doing so will also start a node server which enables live code reloading. With this you can see your changes by pressing cmd+R in the simulator rather than recompiling in Xcode.

For this tutorial we'll be building a simple version of the Movies app that fetches 25 movies that are in theaters and displays them in a ListView.

Hello World #

react-native init will copy Examples/SampleProject to whatever you named your project, in this case AwesomeProject. This is a simple hello world app. You can edit index.ios.js to make changes to the app and then press cmd+R in the simulator to see the changes.

Mocking data #

Before we write the code to fetch actual Rotten Tomatoes data let's mock some data so we can get our hands dirty with React Native. At Facebook we typically declare constants at the top of JS files, just below the requires, but feel free to add the following constant wherever you like. In index.ios.js:

var MOCKED_MOVIES_DATA = [ - {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}}, -];

Render a movie #

We're going to render the title, year, and thumbnail for the movie. Since thumbnail is an Image component in React Native, add Image to the list of React requires below.

var { - AppRegistry, - Image, - StyleSheet, - Text, - View, -} = React;

Now change the render function so that we're rendering the data mentioned above rather than hello world.

render: function() { - var movie = MOCKED_MOVIES_DATA[0]; - return ( - <View style={styles.container}> - <Text>{movie.title}</Text> - <Text>{movie.year}</Text> - <Image source={{uri: movie.posters.thumbnail}} /> - </View> - ); - }

Press cmd+R and you should see "Title" above "2015". Notice that the Image doesn't render anything. This is because we haven't specified the width and height of the image we want to render. This is done via styles. While we're changing the styles let's also clean up the styles we're no longer using.

var styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - }, - thumbnail: { - width: 53, - height: 81, - }, -});

And lastly we need to apply this style to the Image component:

<Image - source={{uri: movie.posters.thumbnail}} - style={styles.thumbnail} - />

Press cmd+R and the image should now render.

- -
- - -

Add some styling #

Great, we've rendered our data. Now let's make it look better. I'd like to put the text to the right of the image and make the title larger and centered within that area:

+---------------------------------+ -|+-------++----------------------+| -|| || Title || -|| Image || || -|| || Year || -|+-------++----------------------+| -+---------------------------------+

We'll need to add another container in order to vertically lay out components within horizontally layed out components.

return ( - <View style={styles.container}> - <Image - source={{uri: movie.posters.thumbnail}} - style={styles.thumbnail} - /> - <View style={styles.rightContainer}> - <Text style={styles.title}>{movie.title}</Text> - <Text style={styles.year}>{movie.year}</Text> - </View> - </View> - );

Not too much has changed, we added a container around the Texts and then moved them after the Image (because they're to the right of the Image). Let's see what the style changes look like:

container: { - flex: 1, - flexDirection: 'row', - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - },

We use FlexBox for layout - see this great guide to learn more about it.

In the above code snippet, we simply added flexDirection: 'row' that will make children of our main container to be layed out horizontally instead of vertically.

Now add another style to the JS style object:

rightContainer: { - flex: 1, - },

This means that the rightContainer takes up the remaining space in the parent container that isn't taken up by the Image. If this doesn't make sense, add a backgroundColor to rightContainer and then try removing the flex: 1. You'll see that this causes the container's size to be the minimum size that fits its children.

Styling the text is pretty straightforward:

title: { - fontSize: 20, - marginBottom: 8, - textAlign: 'center', - }, - year: { - textAlign: 'center', - },

Go ahead and press cmd+R and you'll see the updated view.

- -
- -

Fetching real data #

Fetching data from Rotten Tomatoes's API isn't really relevant to learning React Native so feel free to breeze through this section.

Add the following constants to the top of the file (typically below the requires) to create the REQUEST_URL used to request data with.

/** - * For quota reasons we replaced the Rotten Tomatoes' API with a sample data of - * their very own API that lives in React Native's Github repo. - */ -var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json';

Add some initial state to our application so that we can check this.state.movies === null to determine whether the movies data has been loaded or not. We can set this data when the response comes back with this.setState({movies: moviesData}). Add this code just above the render function inside our React class.

getInitialState: function() { - return { - movies: null, - }; - },

We want to send off the request after the component has finished loading. componentDidMount is a function of React components that React will call exactly once, just after the component has been loaded.

componentDidMount: function() { - this.fetchData(); - },

Now add fetchData function used above to our main component. This method will be responsible for handling data fetching. All you need to do is call this.setState({movies: data}) after resolving the promise chain because the way React works is that setState actually triggers a re-render and then the render function will notice that this.state.movies is no longer null. Note that we call done() at the end of the promise chain - always make sure to call done() or any errors thrown will get swallowed.

fetchData: function() { - fetch(REQUEST_URL) - .then((response) => response.json()) - .then((responseData) => { - this.setState({ - movies: responseData.movies, - }); - }) - .done(); - },

Now modify the render function to render a loading view if we don't have any movies data, and to render the first movie otherwise.

render: function() { - if (!this.state.movies) { - return this.renderLoadingView(); - } - - var movie = this.state.movies[0]; - return this.renderMovie(movie); - }, - - renderLoadingView: function() { - return ( - <View style={styles.container}> - <Text> - Loading movies... - </Text> - </View> - ); - }, - - renderMovie: function(movie) { - return ( - <View style={styles.container}> - <Image - source={{uri: movie.posters.thumbnail}} - style={styles.thumbnail} - /> - <View style={styles.rightContainer}> - <Text style={styles.title}>{movie.title}</Text> - <Text style={styles.year}>{movie.year}</Text> - </View> - </View> - ); - },

Now press cmd+R and you should see "Loading movies..." until the response comes back, then it will render the first movie it fetched from Rotten Tomatoes.

- -
- -

ListView #

Let's now modify this application to render all of this data in a ListView component, rather than just rendering the first movie.

Why is a ListView better than just rendering all of these elements or putting them in a ScrollView? Despite React being fast, rendering a possibly infinite list of elements could be slow. ListView schedules rendering of views so that you only display the ones on screen and those already rendered but off screen are removed from the native view hierarchy.

First thing's first: add the ListView require to the top of the file.

var { - AppRegistry, - Image, - ListView, - StyleSheet, - Text, - View, -} = React;

Now modify the render function so that once we have our data it renders a ListView of movies instead of a single movie.

render: function() { - if (!this.state.loaded) { - return this.renderLoadingView(); - } - - return ( - <ListView - dataSource={this.state.dataSource} - renderRow={this.renderMovie} - style={styles.listView} - /> - ); - },

The DataSource is an interface that ListView is using to determine which rows have changed over the course of updates.

You'll notice we used dataSource from this.state. The next step is to add an empty dataSource to the object returned by getInitialState. Also, now that we're storing the data in dataSource, we should no longer use this.state.movies to avoid storing data twice. We can use boolean property of the state (this.state.loaded) to tell whether data fetching has finished.

getInitialState: function() { - return { - dataSource: new ListView.DataSource({ - rowHasChanged: (row1, row2) => row1 !== row2, - }), - loaded: false, - }; - },

And here is the modified fetchData method that updates the state accordingly:

fetchData: function() { - fetch(REQUEST_URL) - .then((response) => response.json()) - .then((responseData) => { - this.setState({ - dataSource: this.state.dataSource.cloneWithRows(responseData.movies), - loaded: true, - }); - }) - .done(); - },

Finally, we add styles for the ListView component to the styles JS object:

listView: { - paddingTop: 20, - backgroundColor: '#F5FCFF', - },

And here's the final result:

- -
- -

There's still some work to be done to make it a fully functional app such as: adding navigation, search, infinite scroll loading, etc. Check the Movies Example to see it all working.

Final source code #

/** - * Sample React Native App - * https://github.com/facebook/react-native - */ -'use strict'; - -var React = require('react-native'); -var { - AppRegistry, - Image, - ListView, - StyleSheet, - Text, - View, -} = React; - -var API_KEY = '7waqfqbprs7pajbz28mqf6vz'; -var API_URL = 'http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json'; -var PAGE_SIZE = 25; -var PARAMS = '?apikey=' + API_KEY + '&page_limit=' + PAGE_SIZE; -var REQUEST_URL = API_URL + PARAMS; - -var AwesomeProject = React.createClass({ - getInitialState: function() { - return { - dataSource: new ListView.DataSource({ - rowHasChanged: (row1, row2) => row1 !== row2, - }), - loaded: false, - }; - }, - - componentDidMount: function() { - this.fetchData(); - }, - - fetchData: function() { - fetch(REQUEST_URL) - .then((response) => response.json()) - .then((responseData) => { - this.setState({ - dataSource: this.state.dataSource.cloneWithRows(responseData.movies), - loaded: true, - }); - }) - .done(); - }, - - render: function() { - if (!this.state.loaded) { - return this.renderLoadingView(); - } - - return ( - <ListView - dataSource={this.state.dataSource} - renderRow={this.renderMovie} - style={styles.listView} - /> - ); - }, - - renderLoadingView: function() { - return ( - <View style={styles.container}> - <Text> - Loading movies... - </Text> - </View> - ); - }, - - renderMovie: function(movie) { - return ( - <View style={styles.container}> - <Image - source={{uri: movie.posters.thumbnail}} - style={styles.thumbnail} - /> - <View style={styles.rightContainer}> - <Text style={styles.title}>{movie.title}</Text> - <Text style={styles.year}>{movie.year}</Text> - </View> - </View> - ); - }, -}); - -var styles = StyleSheet.create({ - container: { - flex: 1, - flexDirection: 'row', - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - }, - rightContainer: { - flex: 1, - }, - title: { - fontSize: 20, - marginBottom: 8, - textAlign: 'center', - }, - year: { - textAlign: 'center', - }, - thumbnail: { - width: 53, - height: 81, - }, - listView: { - paddingTop: 20, - backgroundColor: '#F5FCFF', - }, -}); - -AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
\ No newline at end of file diff --git a/docs/vibrationios.html b/docs/vibrationios.html deleted file mode 100644 index 862cb074473..00000000000 --- a/docs/vibrationios.html +++ /dev/null @@ -1,53 +0,0 @@ -React Native | A framework for building native apps using React

VibrationIOS

The Vibration API is exposed at VibrationIOS.vibrate(). On iOS, calling this -function will trigger a one second vibration. The vibration is asynchronous -so this method will return immediately.

There will be no effect on devices that do not support Vibration, eg. the iOS -simulator.

Vibration patterns are currently unsupported.

Methods #

static vibrate() #

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - StyleSheet, - View, - Text, - TouchableHighlight, - VibrationIOS -} = React; - -exports.framework = 'React'; -exports.title = 'VibrationIOS'; -exports.description = 'Vibration API for iOS'; -exports.examples = [{ - title: 'VibrationIOS.vibrate()', - render() { - return ( - <TouchableHighlight - style={styles.wrapper} - onPress={() => VibrationIOS.vibrate()}> - <View style={styles.button}> - <Text>Vibrate</Text> - </View> - </TouchableHighlight> - ); - }, -}]; - -var styles = StyleSheet.create({ - wrapper: { - borderRadius: 5, - marginBottom: 5, - }, - button: { - backgroundColor: '#eeeeee', - padding: 10, - }, -});
\ No newline at end of file diff --git a/docs/videos.html b/docs/videos.html deleted file mode 100644 index 3a7491b051d..00000000000 --- a/docs/videos.html +++ /dev/null @@ -1,27 +0,0 @@ -React Native | A framework for building native apps using React

Videos

- - - - - -

The Changelog #149 #

With Christopher "vjeux" Chedeau and Spencer Ahrens

- -

JSJabber #146 #

With Christopher "vjeux" Chedeau and Jordan Walke

-
\ No newline at end of file diff --git a/docs/view.html b/docs/view.html deleted file mode 100644 index f760e2c68dd..00000000000 --- a/docs/view.html +++ /dev/null @@ -1,173 +0,0 @@ -React Native | A framework for building native apps using React

View

The most fundamental component for building UI, View is a -container that supports layout with flexbox, style, some touch handling, and -accessibility controls, and is designed to be nested inside other views and -to have 0 to many children of any type. View maps directly to the native -view equivalent on whatever platform react is running on, whether that is a -UIView, <div>, android.view, etc. This example creates a View that -wraps two colored boxes and custom component in a row with padding.

<View style={{flexDirection: 'row', height: 100, padding: 20}}> - <View style={{backgroundColor: 'blue', flex: 0.3}} /> - <View style={{backgroundColor: 'red', flex: 0.5}} /> - <MyCustomComponent {...customProps} /> -</View>

Views are designed to be used with StyleSheets for clarity and -performance, although inline styles are also supported.

Edit on GitHubProps #

accessibilityLabel string #

Overrides the text that's read by the screen reader when the user interacts -with the element. By default, the label is constructed by traversing all the -children and accumulating all the Text nodes separated by space.

accessible bool #

When true, indicates that the view is an accessibility element. By default, -all the touchable elements are accessible.

onMoveShouldSetResponder function #

For most touch interactions, you'll simply want to wrap your component in -TouchableHighlight or TouchableOpacity. Check out Touchable.js, -ScrollResponder.js and ResponderEventPlugin.js for more discussion.

onResponderGrant function #

onResponderMove function #

onResponderReject function #

onResponderRelease function #

onResponderTerminate function #

onResponderTerminationRequest function #

onStartShouldSetResponder function #

onStartShouldSetResponderCapture function #

pointerEvents enum('box-none', 'none', 'box-only', 'auto') #

In the absence of auto property, none is much like CSS's none -value. box-none is as if you had applied the CSS class:

.box-none { - pointer-events: none; -} -.box-none * { - pointer-events: all; -}

box-only is the equivalent of

.box-only { - pointer-events: all; -} -.box-only * { - pointer-events: none; -}

But since pointerEvents does not affect layout/appearance, and we are -already deviating from the spec by adding additional modes, we opt to not -include pointerEvents on style. On some platforms, we would need to -implement it as a className anyways. Using style or not is an -implementation detail of the platform.

removeClippedSubviews bool #

This is a special performance property exposed by RCTView and is useful -for scrolling content when there are many subviews, most of which are -offscreen. For this property to be effective, it must be applied to a -view that contains many subviews that extend outside its bound. The -subviews must also have overflow: hidden, as should the containing view -(or one of its superviews).

style style #

backgroundColor string
borderBottomColor string
borderColor string
borderLeftColor string
borderRadius number
borderRightColor string
borderTopColor string
opacity number
overflow enum('visible', 'hidden')
rotation number
scaleX number
scaleY number
shadowColor string
shadowOffset {h: number, w: number}
shadowOpacity number
shadowRadius number
transformMatrix [number]
translateX number
translateY number

testID string #

Used to locate this view in end-to-end tests.

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var { - StyleSheet, - Text, - View, -} = React; - -var styles = StyleSheet.create({ - box: { - backgroundColor: '#527FE4', - borderColor: '#000033', - borderWidth: 1, - } -}); - -exports.title = '<View>'; -exports.description = 'Basic building block of all UI.'; -exports.displayName = 'ViewExample'; -exports.examples = [ - { - title: 'Background Color', - render: function() { - return ( - <View style={{backgroundColor: '#527FE4', padding: 5}}> - <Text style={{fontSize: 11}}> - Blue background - </Text> - </View> - ); - }, - }, { - title: 'Border', - render: function() { - return ( - <View style={{borderColor: '#527FE4', borderWidth: 5, padding: 10}}> - <Text style={{fontSize: 11}}>5px blue border</Text> - </View> - ); - }, - }, { - title: 'Padding/Margin', - render: function() { - return ( - <View style={{borderColor: '#bb0000', borderWidth: 0.5}}> - <View style={[styles.box, {padding: 5}]}> - <Text style={{fontSize: 11}}>5px padding</Text> - </View> - <View style={[styles.box, {margin: 5}]}> - <Text style={{fontSize: 11}}>5px margin</Text> - </View> - <View style={[styles.box, {margin: 5, padding: 5, alignSelf: 'flex-start'}]}> - <Text style={{fontSize: 11}}> - 5px margin and padding, - </Text> - <Text style={{fontSize: 11}}> - widthAutonomous=true - </Text> - </View> - </View> - ); - }, - }, { - title: 'Border Radius', - render: function() { - return ( - <View style={{borderWidth: 0.5, borderRadius: 5, padding: 5}}> - <Text style={{fontSize: 11}}> - Too much use of `borderRadius` (especially large radii) on - anything which is scrolling may result in dropped frames. - Use sparingly. - </Text> - </View> - ); - }, - }, { - title: 'Circle with Border Radius', - render: function() { - return ( - <View style={{borderRadius: 10, borderWidth: 1, width: 20, height: 20}} /> - ); - }, - }, { - title: 'Overflow', - render: function() { - return ( - <View style={{flexDirection: 'row'}}> - <View - style={{ - width: 95, - height: 10, - marginRight: 10, - marginBottom: 5, - overflow: 'hidden', - borderWidth: 0.5, - }}> - <View style={{width: 200, height: 20}}> - <Text>Overflow hidden</Text> - </View> - </View> - <View style={{width: 95, height: 10, marginBottom: 5, borderWidth: 0.5}}> - <View style={{width: 200, height: 20}}> - <Text>Overflow visible</Text> - </View> - </View> - </View> - ); - }, - }, { - title: 'Opacity', - render: function() { - return ( - <View> - <View style={{opacity: 0}}><Text>Opacity 0</Text></View> - <View style={{opacity: 0.1}}><Text>Opacity 0.1</Text></View> - <View style={{opacity: 0.3}}><Text>Opacity 0.3</Text></View> - <View style={{opacity: 0.5}}><Text>Opacity 0.5</Text></View> - <View style={{opacity: 0.7}}><Text>Opacity 0.7</Text></View> - <View style={{opacity: 0.9}}><Text>Opacity 0.9</Text></View> - <View style={{opacity: 1}}><Text>Opacity 1</Text></View> - </View> - ); - }, - }, -];
\ No newline at end of file diff --git a/docs/webview.html b/docs/webview.html deleted file mode 100644 index 52c39b8195d..00000000000 --- a/docs/webview.html +++ /dev/null @@ -1,222 +0,0 @@ -React Native | A framework for building native apps using React

WebView

Edit on GitHubProps #

automaticallyAdjustContentInsets bool #

contentInset {top: number, left: number, bottom: number, right: number} #

html string #

onNavigationStateChange function #

renderError function #

renderLoading function #

shouldInjectAJAXHandler bool #

startInLoadingState bool #

url string #

Edit on GitHubExamples #

'use strict'; - -var React = require('react-native'); -var StyleSheet = require('StyleSheet'); -var { - StyleSheet, - Text, - TextInput, - TouchableOpacity, - View, - WebView -} = React; - -var HEADER = '#3b5998'; -var BGWASH = 'rgba(255,255,255,0.8)'; -var DISABLED_WASH = 'rgba(255,255,255,0.25)'; - -var TEXT_INPUT_REF = 'urlInput'; -var WEBVIEW_REF = 'webview'; -var DEFAULT_URL = 'https://m.facebook.com'; - -var WebViewExample = React.createClass({ - - getInitialState: function() { - return { - url: DEFAULT_URL, - status: 'No Page Loaded', - backButtonEnabled: false, - forwardButtonEnabled: false, - loading: true, - }; - }, - - inputText: '', - - handleTextInputChange: function(event) { - this.inputText = event.nativeEvent.text; - }, - - render: function() { - this.inputText = this.state.url; - - return ( - <View style={[styles.container]}> - <View style={[styles.addressBarRow]}> - <TouchableOpacity onPress={this.goBack}> - <View style={this.state.backButtonEnabled ? styles.navButton : styles.disabledButton}> - <Text> - {'<'} - </Text> - </View> - </TouchableOpacity> - <TouchableOpacity onPress={this.goForward}> - <View style={this.state.forwardButtonEnabled ? styles.navButton : styles.disabledButton}> - <Text> - {'>'} - </Text> - </View> - </TouchableOpacity> - <TextInput - ref={TEXT_INPUT_REF} - autoCapitalize="none" - value={this.state.url} - onSubmitEditing={this.onSubmitEditing} - onChange={this.handleTextInputChange} - clearButtonMode="while-editing" - style={styles.addressBarTextInput} - /> - <TouchableOpacity onPress={this.pressGoButton}> - <View style={styles.goButton}> - <Text> - Go! - </Text> - </View> - </TouchableOpacity> - </View> - <WebView - ref={WEBVIEW_REF} - automaticallyAdjustContentInsets={false} - style={styles.webView} - url={this.state.url} - onNavigationStateChange={this.onNavigationStateChange} - startInLoadingState={true} - /> - <View style={styles.statusBar}> - <Text style={styles.statusBarText}>{this.state.status}</Text> - </View> - </View> - ); - }, - - goBack: function() { - this.refs[WEBVIEW_REF].goBack(); - }, - - goForward: function() { - this.refs[WEBVIEW_REF].goForward(); - }, - - reload: function() { - this.refs[WEBVIEW_REF].reload(); - }, - - onNavigationStateChange: function(navState) { - this.setState({ - backButtonEnabled: navState.canGoBack, - forwardButtonEnabled: navState.canGoForward, - url: navState.url, - status: navState.title, - loading: navState.loading, - }); - }, - - onSubmitEditing: function(event) { - this.pressGoButton(); - }, - - pressGoButton: function() { - var url = this.inputText.toLowerCase(); - if (url === this.state.url) { - this.reload(); - } else { - this.setState({ - url: url, - }); - } - // dismiss keyoard - this.refs[TEXT_INPUT_REF].blur(); - }, - -}); - -var styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: HEADER, - }, - addressBarRow: { - flexDirection: 'row', - padding: 8, - }, - webView: { - backgroundColor: BGWASH, - height: 350, - }, - addressBarTextInput: { - backgroundColor: BGWASH, - borderColor: 'transparent', - borderRadius: 3, - borderWidth: 1, - height: 24, - paddingLeft: 10, - paddingTop: 3, - paddingBottom: 3, - flex: 1, - fontSize: 14, - }, - navButton: { - width: 20, - padding: 3, - marginRight: 3, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: BGWASH, - borderColor: 'transparent', - borderRadius: 3, - }, - disabledButton: { - width: 20, - padding: 3, - marginRight: 3, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: DISABLED_WASH, - borderColor: 'transparent', - borderRadius: 3, - }, - goButton: { - height: 24, - padding: 3, - marginLeft: 8, - alignItems: 'center', - backgroundColor: BGWASH, - borderColor: 'transparent', - borderRadius: 3, - alignSelf: 'stretch', - }, - statusBar: { - flexDirection: 'row', - alignItems: 'center', - paddingLeft: 5, - height: 22, - }, - statusBarText: { - color: 'white', - fontSize: 13, - }, - spinner: { - width: 20, - marginRight: 6, - }, -}); - -exports.title = '<WebView>'; -exports.description = 'Base component to display web content'; -exports.examples = [ - { - title: 'WebView', - render(): ReactElement { return <WebViewExample />; } - } -];
\ No newline at end of file diff --git a/img/AddToBuildPhases.png b/img/AddToBuildPhases.png deleted file mode 100644 index 7b83937020d..00000000000 Binary files a/img/AddToBuildPhases.png and /dev/null differ diff --git a/img/AddToLibraries.png b/img/AddToLibraries.png deleted file mode 100644 index 652cdfd1cfd..00000000000 Binary files a/img/AddToLibraries.png and /dev/null differ diff --git a/img/AddToSearchPaths.png b/img/AddToSearchPaths.png deleted file mode 100644 index ccbe819ba78..00000000000 Binary files a/img/AddToSearchPaths.png and /dev/null differ diff --git a/img/EmbeddedAppContainerViewExample.png b/img/EmbeddedAppContainerViewExample.png deleted file mode 100644 index 6130dfb1e10..00000000000 Binary files a/img/EmbeddedAppContainerViewExample.png and /dev/null differ diff --git a/img/EmbeddedAppExample.png b/img/EmbeddedAppExample.png deleted file mode 100644 index fefd3069ddf..00000000000 Binary files a/img/EmbeddedAppExample.png and /dev/null differ diff --git a/img/TutorialFinal.png b/img/TutorialFinal.png deleted file mode 100644 index 2f05b13e2ea..00000000000 Binary files a/img/TutorialFinal.png and /dev/null differ diff --git a/img/TutorialMock.png b/img/TutorialMock.png deleted file mode 100644 index 6a267d08995..00000000000 Binary files a/img/TutorialMock.png and /dev/null differ diff --git a/img/TutorialSingleFetched.png b/img/TutorialSingleFetched.png deleted file mode 100644 index 914cb8833b9..00000000000 Binary files a/img/TutorialSingleFetched.png and /dev/null differ diff --git a/img/TutorialStyledMock.png b/img/TutorialStyledMock.png deleted file mode 100644 index 48fb1c5e732..00000000000 Binary files a/img/TutorialStyledMock.png and /dev/null differ diff --git a/img/chrome_breakpoint.png b/img/chrome_breakpoint.png deleted file mode 100644 index d37c9538b03..00000000000 Binary files a/img/chrome_breakpoint.png and /dev/null differ diff --git a/img/favicon.png b/img/favicon.png deleted file mode 100644 index 22c120d09b2..00000000000 Binary files a/img/favicon.png and /dev/null differ diff --git a/img/header_logo.png b/img/header_logo.png deleted file mode 100644 index 8858ffa29da..00000000000 Binary files a/img/header_logo.png and /dev/null differ diff --git a/img/opengraph.png b/img/opengraph.png deleted file mode 100644 index 0e9e1d3dea0..00000000000 Binary files a/img/opengraph.png and /dev/null differ diff --git a/index.html b/index.html deleted file mode 100644 index 9542b746657..00000000000 --- a/index.html +++ /dev/null @@ -1,140 +0,0 @@ -React Native | A framework for building native apps using React
React Native
A framework for building native apps using React

React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.

Native iOS Components

With React Native, you can use the standard platform components such as UITabBar and UINavigationController on iOS. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and NavigatorIOS.

var React = require('react-native'); -var { TabBarIOS, NavigatorIOS } = React; - -var App = React.createClass({ - render: function() { - return ( - <TabBarIOS> - <TabBarIOS.Item title="React Native" selected={true}> - <NavigatorIOS initialRoute={{ title: 'React Native' }} /> - </TabBarIOS.Item> - </TabBarIOS> - ); - }, -});

Asynchronous Execution

All operations between the JavaScript application code and the native platform are performed asynchronously, and the native modules can also make use of additional threads as well. This means we can decode images off of the main thread, save to disk in the background, measure text and compute layouts without blocking the UI, and more. As a result, React Native apps are naturally fluid and responsive. The communication is also fully serializable, which allows us to leverage Chrome Developer Tools to debug the JavaScript while running the complete app, either in the simulator or on a physical device.

See Debugging.

Touch Handling

iOS has a very powerful system called the Responder Chain to negotiate touches in complex view hierarchies which does not have a universal analog on the web. React Native implements a similar responder system and provides high level components such as TouchableHighlight that integrate properly with scroll views and other elements without any additional configuration.

var React = require('react-native'); -var { ScrollView, TouchableHighlight, Text } = React; - -var TouchDemo = React.createClass({ - render: function() { - return ( - <ScrollView> - <TouchableHighlight onPress={() => console.log('pressed')}> - <Text>Proper Touch Handling</Text> - </TouchableHighlight> - </ScrollView> - ); - }, -});

Flexbox and Styling

Laying out views should be easy, which is why we brought the flexbox layout model from the web to React Native. Flexbox makes it simple to build the most common UI layouts, such as stacked and nested boxes with margin and padding. React Native also supports common web syles, such as fontWeight, and the StyleSheet abstraction provides an optimized mechanism to declare all your styles and layout right along with the components that use them and apply them inline.

var React = require('react-native'); -var { Image, StyleSheet, Text, View } = React; - -var ReactNative = React.createClass({ - render: function() { - return ( - <View style={styles.row}> - <Image - source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}} - style={styles.image} - /> - <View style={styles.text}> - <Text style={styles.title}> - React Native - </Text> - <Text style={styles.subtitle}> - Build high quality mobile apps using React - </Text> - </View> - </View> - ); - }, -}); -var styles = StyleSheet.create({ - row: { flexDirection: 'row', margin: 40 }, - image: { width: 40, height: 40, marginRight: 10 }, - text: { flex: 1, justifyContent: 'center'}, - title: { fontSize: 11, fontWeight: 'bold' }, - subtitle: { fontSize: 10 }, -});

Polyfills

React Native is focused on changing the way view code is written. For the rest, we look to the web for universal standards and polyfill those APIs where appropriate. You can use npm to install JavaScript libraries that work on top of the functionality baked into React Native, such as XMLHttpRequest, window.requestAnimationFrame, and navigator.geolocation. We are working on expanding the available APIs, and are excited for the Open Source community to contribute as well.

var React = require('react-native'); -var { Text } = React; - -var GeoInfo = React.createClass({ - getInitialState: function() { - return { position: 'unknown' }; - }, - componentDidMount: function() { - navigator.geolocation.getCurrentPosition( - (position) => this.setState({position}), - (error) => console.error(error) - ); - }, - render: function() { - return ( - <Text> - Position: {JSON.stringify(this.state.position)} - </Text> - ); - }, -});

Extensibility

It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you've already built, and can import and use your favorite native libraries. To create a simple module in iOS, create a new class that implements the RCTBridgeModule protocol, and add RCT_EXPORT to the function you want to make available in JavaScript.

// Objective-C - -#import "RCTBridgeModule.h" - -@interface MyCustomModule : NSObject <RCTBridgeModule> -@end - -@implementation MyCustomModule - -- (void)processString:(NSString *)input callback:(RCTResponseSenderBlock)callback -{ - RCT_EXPORT(); // available as NativeModules.MyCustomModule.processString - callback(@[[input stringByReplacingOccurrencesOfString:@"Goodbye" withString:@"Hello"];]]); -} -@end
// JavaScript - -var React = require('react-native'); -var { NativeModules, Text } = React; - -var Message = React.createClass({ - render: function() { - getInitialState() { - return { text: 'Goodbye World.' }; - }, - componentDidMount() { - NativeModules.MyCustomModule.processString(this.state.text, (text) => { - this.setState({text}); - }); - }, - return ( - <Text>{this.state.text}</Text> - ); - }, -});

Custom iOS views can be exposed by subclassing RCTViewManager, implementing a -(UIView *)view method, and exporting properties with the RCT_EXPORT_VIEW_PROPERTY macro. Then a simple JavaScript file connects the dots.

// Objective-C - -#import "RCTViewManager.h" - -@interface MyCustomViewManager : RCTViewManager -@end - -@implementation MyCustomViewManager - -- (UIView *)view -{ - return [[MyCustomView alloc] init]; -} - -RCT_EXPORT_VIEW_PROPERTY(myCustomProperty); -@end
// JavaScript - -module.exports = createReactIOSNativeComponentClass({ - validAttributes: { myCustomProperty: true }, - uiViewClassName: 'MyCustomView', -});
\ No newline at end of file diff --git a/support.html b/support.html deleted file mode 100644 index e75d2890dae..00000000000 --- a/support.html +++ /dev/null @@ -1,12 +0,0 @@ -React Native | A framework for building native apps using React

Need help?

React Native is worked on full-time by Facebook's product infrastructure user interface engineering teams. They're often around and available for questions.

Stack Overflow #

Many members of the community use Stack Overflow to ask questions. Read through the existing questions tagged with react-native or ask your own!

IRC #

Many developers and users idle on Freenode.net's IRC network in #reactnative on freenode.

Twitter #

#reactnative hash tag on Twitter is used to keep up with the latest React Native news.

\ No newline at end of file