diff --git a/docs/NativeComponentsIOS.md b/docs/NativeComponentsIOS.md index 986dd92047e53a..3ab1dfadd7508a 100644 --- a/docs/NativeComponentsIOS.md +++ b/docs/NativeComponentsIOS.md @@ -294,7 +294,7 @@ Since all our native react views are subclasses of `UIView`, most style attribut ```javascript // DatePickerIOS.ios.js -var RCTDatePickerIOSConsts = require('NativeModules').UIManager.RCTDatePicker.Constants; +var RCTDatePickerIOSConsts = require('react-native').NativeModules.UIManager.RCTDatePicker.Constants; ... render: function() { return ( diff --git a/docs/NativeModulesIOS.md b/docs/NativeModulesIOS.md index cd6c21f89b537d..1fa4f93fbb6a90 100644 --- a/docs/NativeModulesIOS.md +++ b/docs/NativeModulesIOS.md @@ -50,7 +50,7 @@ RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location) Now, from your JavaScript file you can call the method like this: ```javascript -var CalendarManager = require('NativeModules').CalendarManager; +var CalendarManager = require('react-native').NativeModules.CalendarManager; CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey'); ``` diff --git a/docs/Timers.md b/docs/Timers.md index 44cc093aec52a9..9f8e2ace0001de 100644 --- a/docs/Timers.md +++ b/docs/Timers.md @@ -57,6 +57,8 @@ InteractionManager.clearInteractionHandle(handle); 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. +This library does not ship with React Native - in order to use it on your project, you will need to install it with `npm i react-timer-mixin --save` from your project directory. + ```javascript var TimerMixin = require('react-timer-mixin'); diff --git a/packager/react-packager/src/DependencyResolver/polyfills/console.js b/packager/react-packager/src/DependencyResolver/polyfills/console.js index ff2ff39ff247d5..447d55a54e4b66 100644 --- a/packager/react-packager/src/DependencyResolver/polyfills/console.js +++ b/packager/react-packager/src/DependencyResolver/polyfills/console.js @@ -367,6 +367,9 @@ }; function setupConsole(global) { + + var originalConsole = global.console; + if (!global.nativeLoggingHook) { return; } @@ -456,6 +459,17 @@ table: consoleTablePolyfill }; + // If available, also call the original `console` method since that is + // sometimes useful, Ex. On OS X, this will let you see rich output to + // the Safari REPL console + Object.keys(global.console).forEach(methodName => { + var reactNativeMethod = global.console[methodName]; + global.console[methodName] = function() { + originalConsole[methodName].apply(originalConsole, arguments); + reactNativeMethod.apply(global.console, arguments); + } + }); + } if (typeof module !== 'undefined') { diff --git a/website/layout/AutodocsLayout.js b/website/layout/AutodocsLayout.js index b9bef328c7c2c7..bd6ccfb55aa5c9 100644 --- a/website/layout/AutodocsLayout.js +++ b/website/layout/AutodocsLayout.js @@ -264,6 +264,20 @@ var APIDoc = React.createClass({ }); var HeaderWithGithub = React.createClass({ + + renderRunnableLink: function() { + if (this.props.metadata && this.props.metadata.runnable) { + return ( + + Run this example + + ); + } + }, + render: function() { return ( @@ -272,6 +286,7 @@ var HeaderWithGithub = React.createClass({ href={'https://github.com/facebook/react-native/blob/master/' + this.props.path}> Edit on GitHub + {this.renderRunnableLink()} {this.props.title} ); @@ -296,7 +311,7 @@ var Autodocs = React.createClass({ ); }, - renderExample: function(docs) { + renderExample: function(docs, metadata) { if (!docs.example) { return; } @@ -306,6 +321,7 @@ var Autodocs = React.createClass({ {docs.example.content.replace(/^[\s\S]*?\*\//, '').trim()} @@ -330,7 +346,7 @@ var Autodocs = React.createClass({

{metadata.title}

{content} {this.renderFullDescription(docs)} - {this.renderExample(docs)} + {this.renderExample(docs, metadata)}
{metadata.previous && ← Prev} {metadata.next && Next →} diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index 45cd16fbbea999..57ea2c6a775e3d 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -44,6 +44,16 @@ function getExample(componentName) { }; } +// Determines whether a component should have a link to a runnable example + +function isRunnable(componentName) { + if (componentName === 'AlertIOS') { + return true; + } + + return false; +} + // Hide a component from the sidebar by making it return false from // this function function shouldDisplayInSidebar(componentName) { @@ -99,6 +109,7 @@ function componentsToMarkdown(type, json, filepath, i, styles) { 'permalink: docs/' + slugify(componentName) + '.html', 'next: ' + next, 'sidebar: ' + shouldDisplayInSidebar(componentName), + 'runnable:' + isRunnable(componentName), '---', JSON.stringify(json, null, 2), ].filter(function(line) { return line; }).join('\n'); diff --git a/website/src/react-native/css/react-native.css b/website/src/react-native/css/react-native.css index 8fd1797f78b433..902d2a4a47de5a 100644 --- a/website/src/react-native/css/react-native.css +++ b/website/src/react-native/css/react-native.css @@ -973,6 +973,12 @@ div[data-twttr-id] iframe { float: right; } +.run-example { + font-size: 15px; + float: right; + margin-right: 20px; +} + #content { display: none; } @@ -1043,4 +1049,3 @@ div[data-twttr-id] iframe { margin: 0; } } -