mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3de2e98ec0
Deploy website version based on c9c34bcae09207d55fc8663cc7a2a7ecb83a9811
511 lines
73 KiB
HTML
511 lines
73 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Navigator · React Native</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="<p><code>Navigator</code> handles the transition between different scenes in your app. It is implemented in JavaScript and is available on both iOS and Android. If you are targeting iOS only, you may also want to consider using <code>NavigatorIOS</code> as it leverages native UIKit navigation.</p>
|
||
"/><meta name="docsearch:version" content="0.34"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Navigator · React Native"/><meta property="og:type" content="website"/><meta property="og:url" content="https://facebook.github.io/react-native/"/><meta property="og:description" content="<p><code>Navigator</code> handles the transition between different scenes in your app. It is implemented in JavaScript and is available on both iOS and Android. If you are targeting iOS only, you may also want to consider using <code>NavigatorIOS</code> as it leverages native UIKit navigation.</p>
|
||
"/><meta name="twitter:card" content="summary"/><link rel="shortcut icon" href="/react-native/img/favicon.png"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/solarized-dark.min.css"/><link rel="alternate" type="application/atom+xml" href="https://facebook.github.io/react-native/blog/atom.xml" title="React Native Blog ATOM Feed"/><link rel="alternate" type="application/rss+xml" href="https://facebook.github.io/react-native/blog/feed.xml" title="React Native Blog RSS Feed"/><script>
|
||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||
|
||
ga('create', 'UA-41298772-2', 'auto');
|
||
ga('send', 'pageview');
|
||
</script><script type="text/javascript" src="https://snack.expo.io/embed.js"></script><script type="text/javascript" src="/react-native/js/codeblocks.js"></script><script src="https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js"></script><script>
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
addBackToTop(
|
||
{"zIndex":100}
|
||
)
|
||
});
|
||
</script><script src="/react-native/js/scrollSpy.js"></script><link rel="stylesheet" href="/react-native/css/prism.css"/><link rel="stylesheet" href="/react-native/css/main.css"/><script src="/react-native/js/codetabs.js"></script></head><body class="sideNavVisible"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/react-native/"><img class="logo" src="/react-native/img/header_logo.png" alt="React Native"/><h2 class="headerTitleWithLogo">React Native</h2></a><a href="/react-native/versions"><h3>0.34</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/react-native/docs/0.34/getting-started" target="_self">Docs</a></li><li class="siteNavGroupActive"><a href="/react-native/docs/0.34/activityindicator" target="_self">API</a></li><li class=""><a href="/react-native/help" target="_self">Community</a></li><li class=""><a href="/react-native/blog/" target="_self">Blog</a></li><li class="navSearchWrapper reactNavSearchWrapper"><input type="text" id="search_input_react" placeholder="Search" title="Search"/></li><li class=""><a href="https://github.com/facebook/react-native" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Components</span></h2></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">The Basics<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/getting-started">Getting Started</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/tutorial">Learn the Basics</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/props">Props</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/state">State</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/style">Style</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/height-and-width">Height and Width</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/flexbox">Layout with Flexbox</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/handling-text-input">Handling Text Input</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/handling-touches">Handling Touches</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/using-a-scrollview">Using a ScrollView</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/using-a-listview">Using List Views</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/network">Networking</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/more-resources">More Resources</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">Guides<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/components-and-apis">Components and APIs</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/platform-specific-code">Platform Specific Code</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/navigation">Navigating Between Screens</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/images">Images</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/animations">Animations</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/accessibility">Accessibility</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/improvingux">Improving User Experience</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/timers">Timers</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/debugging">Debugging</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/performance">Performance</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/gesture-responder-system">Gesture Responder System</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/javascript-environment">JavaScript Environment</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/direct-manipulation">Direct Manipulation</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/colors">Color Reference</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/integration-with-existing-apps">Integration with Existing Apps</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/running-on-device">Running On Device</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/upgrading">Upgrading to new React Native versions</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/troubleshooting">Troubleshooting</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/native-modules-setup">Native Modules Setup</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">Guides (iOS)<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/native-modules-ios">Native Modules</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/native-components-ios">Native UI Components</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/linking-libraries-ios">Linking Libraries</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/running-on-simulator-ios">Running On Simulator</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/communication-ios">Communication between native and React Native</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/building-for-apple-tv">Building For TV Devices</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/app-extensions">App Extensions</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">Guides (Android)<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/native-modules-android">Native Modules</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/native-components-android">Native UI Components</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/headless-js-android">Headless JS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/signed-apk-android">Generating Signed APK</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/removing-default-permissions">Removing Default Permissions</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">Components<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/activityindicator">ActivityIndicator</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/datepickerios">DatePickerIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/drawerlayoutandroid">DrawerLayoutAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/image">Image</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/keyboardavoidingview">KeyboardAvoidingView</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/modal">Modal</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/react-native/docs/0.34/navigator">Navigator</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/navigatorios">NavigatorIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/picker">Picker</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/pickerios">PickerIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/progressbarandroid">ProgressBarAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/progressviewios">ProgressViewIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/refreshcontrol">RefreshControl</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/scrollview">ScrollView</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/segmentedcontrolios">SegmentedControlIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/slider">Slider</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/snapshotviewios">SnapshotViewIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/statusbar">StatusBar</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/switch">Switch</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/tabbarios">TabBarIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/tabbarios-item">TabBarIOS.Item</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/text">Text</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/textinput">TextInput</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/toolbarandroid">ToolbarAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/touchablehighlight">TouchableHighlight</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/touchablenativefeedback">TouchableNativeFeedback</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/touchableopacity">TouchableOpacity</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/touchablewithoutfeedback">TouchableWithoutFeedback</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/viewpagerandroid">ViewPagerAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/webview">WebView</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle collapsible">APIs<span class="arrow"><svg width="24" height="24" viewBox="0 0 24 24"><path fill="#565656" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg></span></h3><ul class="hide"><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/actionsheetios">ActionSheetIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/animated">Animated</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/appstate">AppState</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/asyncstorage">AsyncStorage</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/cameraroll">CameraRoll</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/clipboard">Clipboard</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/datepickerandroid">DatePickerAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/dimensions">Dimensions</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/easing">Easing</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/geolocation">Geolocation</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/imageeditor">ImageEditor</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/imagepickerios">ImagePickerIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/imagestore">ImageStore</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/image-style-props">Image Style Props</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/interactionmanager">InteractionManager</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/layout-props">Layout Props</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/layoutanimation">LayoutAnimation</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/linking">Linking</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/netinfo">NetInfo</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/panresponder">PanResponder</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/permissionsandroid">PermissionsAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/pixelratio">PixelRatio</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/pushnotificationios">PushNotificationIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/settings">Settings</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/shadow-props">Shadow Props</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/share">Share</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/statusbarios">StatusBarIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/stylesheet">StyleSheet</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/text-style-props">Text Style Props</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/timepickerandroid">TimePickerAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/toastandroid">ToastAndroid</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/transforms">Transforms</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/vibration">Vibration</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/vibrationios">VibrationIOS</a></li><li class="navListItem"><a class="navItem" href="/react-native/docs/0.34/view-style-props">View Style Props</a></li></ul></div></div></section></div><script>
|
||
var coll = document.getElementsByClassName('collapsible');
|
||
var checkActiveCategory = true;
|
||
for (var i = 0; i < coll.length; i++) {
|
||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||
if (checkActiveCategory){
|
||
for (var j = 0; j < links.length; j++) {
|
||
if (links[j].classList.contains('navListItemActive')){
|
||
coll[i].nextElementSibling.classList.toggle('hide');
|
||
coll[i].childNodes[1].classList.toggle('rotate');
|
||
checkActiveCategory = false;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
coll[i].addEventListener('click', function() {
|
||
var arrow = this.childNodes[1];
|
||
arrow.classList.toggle('rotate');
|
||
var content = this.nextElementSibling;
|
||
content.classList.toggle('hide');
|
||
});
|
||
}
|
||
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||
createToggler('#tocToggler', 'body', 'tocActive');
|
||
|
||
var headings = document.querySelector('.toc-headings');
|
||
headings && headings.addEventListener('click', function(event) {
|
||
var el = event.target;
|
||
while(el !== headings){
|
||
if (el.tagName === 'A') {
|
||
document.body.classList.remove('tocActive');
|
||
break;
|
||
} else{
|
||
el = el.parentNode;
|
||
}
|
||
}
|
||
}, false);
|
||
|
||
function createToggler(togglerSelector, targetSelector, className) {
|
||
var toggler = document.querySelector(togglerSelector);
|
||
var target = document.querySelector(targetSelector);
|
||
|
||
if (!toggler) {
|
||
return;
|
||
}
|
||
|
||
toggler.onclick = function(event) {
|
||
event.preventDefault();
|
||
|
||
target.classList.toggle(className);
|
||
};
|
||
}
|
||
});
|
||
</script></nav></div><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/facebook/react-native-website/blob/master/docs/navigator.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 class="postHeaderTitle">Navigator</h1></header><article><div><span><p><code>Navigator</code> handles the transition between different scenes in your app. It is implemented in JavaScript and is available on both iOS and Android. If you are targeting iOS only, you may also want to consider using <code>NavigatorIOS</code> as it leverages native UIKit navigation.</p>
|
||
<p>To set up the <code>Navigator</code> you provide one or more objects called routes, to identify each scene. You also provide a <code>renderScene</code> function that renders the scene for each route object.</p>
|
||
<pre><code class="hljs css language-javascript"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span>Component<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
|
||
<span class="token keyword">import</span> <span class="token punctuation">{</span>Text<span class="token punctuation">,</span> Navigator<span class="token punctuation">,</span> TouchableHighlight<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react-native'</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">class</span> <span class="token class-name">NavAllDay</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
|
||
<span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">return</span> <span class="token punctuation">(</span>
|
||
<span class="token operator"><</span>Navigator
|
||
initialRoute<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>title<span class="token punctuation">:</span> <span class="token string">'Awesome Scene'</span><span class="token punctuation">,</span> index<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||
renderScene<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span>route<span class="token punctuation">,</span> navigator<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token operator"><</span>Text<span class="token operator">></span>Hello <span class="token punctuation">{</span>route<span class="token punctuation">.</span>title<span class="token punctuation">}</span><span class="token operator">!</span><span class="token operator"><</span><span class="token operator">/</span>Text<span class="token operator">></span><span class="token punctuation">}</span>
|
||
style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>padding<span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||
<span class="token operator">/</span><span class="token operator">></span>
|
||
<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre>
|
||
<p>In the above example, <code>initialRoute</code> is used to specify the first route. It contains a title property that identifies the route. The <code>renderScene</code> prop returns a function that displays text based on the route's title.</p>
|
||
<h2><a class="anchor" aria-hidden="true" id="additional-scenes"></a><a href="#additional-scenes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Additional Scenes</h2>
|
||
<p>The first example demonstrated one scene. To set up multiple scenes, you pass the <code>initialRouteStack</code> prop to <code>Navigator</code>:</p>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">const</span> routes <span class="token operator">=</span> <span class="token punctuation">[</span>
|
||
<span class="token punctuation">{</span>title<span class="token punctuation">:</span> <span class="token string">'First Scene'</span><span class="token punctuation">,</span> index<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">{</span>title<span class="token punctuation">:</span> <span class="token string">'Second Scene'</span><span class="token punctuation">,</span> index<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">]</span><span class="token punctuation">;</span>
|
||
<span class="token keyword">return</span> <span class="token punctuation">(</span>
|
||
<span class="token operator"><</span>Navigator
|
||
initialRoute<span class="token operator">=</span><span class="token punctuation">{</span>routes<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">}</span>
|
||
initialRouteStack<span class="token operator">=</span><span class="token punctuation">{</span>routes<span class="token punctuation">}</span>
|
||
renderScene<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span>route<span class="token punctuation">,</span> navigator<span class="token punctuation">)</span> <span class="token operator">=></span>
|
||
<span class="token operator"><</span>TouchableHighlight onPress<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">if</span> <span class="token punctuation">(</span>route<span class="token punctuation">.</span>index <span class="token operator">===</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
navigator<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>routes<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
|
||
navigator<span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">></span>
|
||
<span class="token operator"><</span>Text<span class="token operator">></span>Hello <span class="token punctuation">{</span>route<span class="token punctuation">.</span>title<span class="token punctuation">}</span><span class="token operator">!</span><span class="token operator"><</span><span class="token operator">/</span>Text<span class="token operator">></span>
|
||
<span class="token operator"><</span><span class="token operator">/</span>TouchableHighlight<span class="token operator">></span>
|
||
<span class="token punctuation">}</span>
|
||
style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>padding<span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||
<span class="token operator">/</span><span class="token operator">></span>
|
||
<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre>
|
||
<p>In the above example, a routes variable is defined with two route objects representing two scenes. Each route has an index property that is used to manage the scene being rendered. The <code>renderScene</code> method is changed to either push or pop the navigator depending on the current route's index. Finally, the <code>Text</code> component in the scene is now wrapped in a <code>TouchableHighlight</code> component to help trigger the navigator transitions.</p>
|
||
<h2><a class="anchor" aria-hidden="true" id="navigation-bar"></a><a href="#navigation-bar" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Navigation Bar</h2>
|
||
<p>You can optionally pass in your own navigation bar by returning a <code>Navigator.NavigationBar</code> component to the <code>navigationBar</code> prop in <code>Navigator</code>. You can configure the navigation bar properties, through the <code>routeMapper</code> prop. There you set up the left, right, and title properties of the navigation bar:</p>
|
||
<pre><code class="hljs"><Navigator
|
||
renderScene={(route, navigator) =>
|
||
<span class="hljs-comment">// ...</span>
|
||
}
|
||
navigationBar={
|
||
<Navigator.NavigationBar
|
||
routeMapper={{
|
||
<span class="hljs-attr">LeftButton</span>: <span class="hljs-function">(<span class="hljs-params">route, navigator, index, navState</span>) =></span>
|
||
{ <span class="hljs-keyword">return</span> (<span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span>></span>Cancel<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>); },
|
||
<span class="hljs-attr">RightButton</span>: <span class="hljs-function">(<span class="hljs-params">route, navigator, index, navState</span>) =></span>
|
||
{ <span class="hljs-keyword">return</span> (<span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span>></span>Done<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>); },
|
||
<span class="hljs-attr">Title</span>: <span class="hljs-function">(<span class="hljs-params">route, navigator, index, navState</span>) =></span>
|
||
{ <span class="hljs-keyword">return</span> (<span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span>></span>Awesome Nav Bar<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>); },
|
||
}}
|
||
style={{<span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">'gray'</span>}}
|
||
/>
|
||
}
|
||
/>
|
||
</code></pre>
|
||
<p>When configuring the left, right, and title items for the navigation bar, you have access to info such as the current route object and navigation state. This allows you to customize the title for each scene as well as the buttons. For example, you can choose to hide the left button for one of the scenes.</p>
|
||
<p>Typically you want buttons to represent the left and right buttons. Building on the previous example, you can set this up as follows:</p>
|
||
<pre><code class="hljs">LeftButton: <span class="hljs-function">(<span class="hljs-params">route, navigator, index, navState</span>) =></span>
|
||
{
|
||
<span class="hljs-keyword">if</span> (route.index === <span class="hljs-number">0</span>) {
|
||
<span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>;
|
||
} <span class="hljs-keyword">else</span> {
|
||
<span class="hljs-keyword">return</span> (
|
||
<span class="xml"><span class="hljs-tag"><<span class="hljs-name">TouchableHighlight</span> <span class="hljs-attr">onPress</span>=<span class="hljs-string">{()</span> =></span> navigator.pop()}>
|
||
<span class="hljs-tag"><<span class="hljs-name">Text</span>></span>Back<span class="hljs-tag"></<span class="hljs-name">Text</span>></span>
|
||
<span class="hljs-tag"></<span class="hljs-name">TouchableHighlight</span>></span></span>
|
||
);
|
||
}
|
||
},
|
||
</code></pre>
|
||
<p>This sets up a left navigator bar button that's visible on scenes after the the first one. When the button is tapped the navigator is popped.</p>
|
||
<p>Another type of navigation bar, with breadcrumbs, is provided by <code>Navigator.BreadcrumbNavigationBar</code>. You can also provide your own navigation bar by passing it through the <code>navigationBar</code> prop.</p>
|
||
<h2><a class="anchor" aria-hidden="true" id="scene-transitions"></a><a href="#scene-transitions" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Scene Transitions</h2>
|
||
<p>To change the animation or gesture properties of the scene, provide a <code>configureScene</code> prop to get the config object for a given route:</p>
|
||
<pre><code class="hljs"><Navigator
|
||
renderScene={<span class="hljs-function">(<span class="hljs-params">route, navigator</span>) =></span>
|
||
<span class="hljs-comment">// ...</span>
|
||
}
|
||
configureScene={<span class="hljs-function">(<span class="hljs-params">route, routeStack</span>) =></span>
|
||
Navigator.SceneConfigs.FloatFromBottom}
|
||
/>
|
||
</code></pre>
|
||
<p>In the above example, the newly pushed scene will float up from the bottom. See <code>Navigator.SceneConfigs</code> for default animations and more info on available <a href="navigator.md#configurescene">scene config options</a>.</p>
|
||
<h3><a class="anchor" aria-hidden="true" id="props"></a><a href="#props" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Props</h3>
|
||
<ul>
|
||
<li><a href="navigator.md#configurescene"><code>configureScene</code></a></li>
|
||
<li><a href="navigator.md#initialroute"><code>initialRoute</code></a></li>
|
||
<li><a href="navigator.md#initialroutestack"><code>initialRouteStack</code></a></li>
|
||
<li><a href="navigator.md#navigationbar"><code>navigationBar</code></a></li>
|
||
<li><a href="navigator.md#navigator"><code>navigator</code></a></li>
|
||
<li><a href="navigator.md#ondidfocus"><code>onDidFocus</code></a></li>
|
||
<li><a href="navigator.md#onwillfocus"><code>onWillFocus</code></a></li>
|
||
<li><a href="navigator.md#renderscene"><code>renderScene</code></a></li>
|
||
<li><a href="navigator.md#scenestyle"><code>sceneStyle</code></a></li>
|
||
</ul>
|
||
<h3><a class="anchor" aria-hidden="true" id="methods"></a><a href="#methods" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Methods</h3>
|
||
<ul>
|
||
<li><a href="navigator.md#immediatelyresetroutestack"><code>immediatelyResetRouteStack</code></a></li>
|
||
<li><a href="navigator.md#jumpto"><code>jumpTo</code></a></li>
|
||
<li><a href="navigator.md#jumpforward"><code>jumpForward</code></a></li>
|
||
<li><a href="navigator.md#jumpback"><code>jumpBack</code></a></li>
|
||
<li><a href="navigator.md#push"><code>push</code></a></li>
|
||
<li><a href="navigator.md#popn"><code>popN</code></a></li>
|
||
<li><a href="navigator.md#pop"><code>pop</code></a></li>
|
||
<li><a href="navigator.md#replaceatindex"><code>replaceAtIndex</code></a></li>
|
||
<li><a href="navigator.md#replace"><code>replace</code></a></li>
|
||
<li><a href="navigator.md#replaceprevious"><code>replacePrevious</code></a></li>
|
||
<li><a href="navigator.md#poptotop"><code>popToTop</code></a></li>
|
||
<li><a href="navigator.md#poptoroute"><code>popToRoute</code></a></li>
|
||
<li><a href="navigator.md#replacepreviousandpop"><code>replacePreviousAndPop</code></a></li>
|
||
<li><a href="navigator.md#resetto"><code>resetTo</code></a></li>
|
||
<li><a href="navigator.md#getcurrentroutes"><code>getCurrentRoutes</code></a></li>
|
||
</ul>
|
||
<hr>
|
||
<h1><a class="anchor" aria-hidden="true" id="reference"></a><a href="#reference" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Reference</h1>
|
||
<h2><a class="anchor" aria-hidden="true" id="props-1"></a><a href="#props-1" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Props</h2>
|
||
<h3><a class="anchor" aria-hidden="true" id="configurescene"></a><a href="#configurescene" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>configureScene</code></h3>
|
||
<p>Optional function where you can configure scene animations and gestures. Will be invoked with <code>route</code> and <code>routeStack</code> parameters, where route corresponds to the current scene being rendered by the <code>Navigator</code> and <code>routeStack</code> is the set of currently mounted routes that the navigator could transition to.</p>
|
||
<p>The function should return a scene configuration object.</p>
|
||
<pre><code class="hljs css language-javascript"><span class="token punctuation">(</span>route<span class="token punctuation">,</span> routeStack<span class="token punctuation">)</span> <span class="token operator">=></span> Navigator<span class="token punctuation">.</span>SceneConfigs<span class="token punctuation">.</span>FloatFromRight<span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Available scene configuration options are:</p>
|
||
<ul>
|
||
<li>Navigator.SceneConfigs.PushFromRight (default)</li>
|
||
<li>Navigator.SceneConfigs.FloatFromRight</li>
|
||
<li>Navigator.SceneConfigs.FloatFromLeft</li>
|
||
<li>Navigator.SceneConfigs.FloatFromBottom</li>
|
||
<li>Navigator.SceneConfigs.FloatFromBottomAndroid</li>
|
||
<li>Navigator.SceneConfigs.FadeAndroid</li>
|
||
<li>Navigator.SceneConfigs.SwipeFromLeft</li>
|
||
<li>Navigator.SceneConfigs.HorizontalSwipeJump</li>
|
||
<li>Navigator.SceneConfigs.HorizontalSwipeJumpFromRight</li>
|
||
<li>Navigator.SceneConfigs.HorizontalSwipeJumpFromLeft</li>
|
||
<li>Navigator.SceneConfigs.VerticalUpSwipeJump</li>
|
||
<li>Navigator.SceneConfigs.VerticalDownSwipeJump</li>
|
||
</ul>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>function</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="initialroute"></a><a href="#initialroute" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>initialRoute</code></h3>
|
||
<p>The initial route for navigation. A route is an object that the navigator will use to identify each scene it renders.</p>
|
||
<p>If both <code>initialRoute</code> and <code>initialRouteStack</code> props are passed to <code>Navigator</code>, then <code>initialRoute</code> must be in a route in <code>initialRouteStack</code>. If <code>initialRouteStack</code> is passed as a prop but <code>initialRoute</code> is not, then <code>initialRoute</code> will default internally to the last item in <code>initialRouteStack</code>.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>object</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="initialroutestack"></a><a href="#initialroutestack" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>initialRouteStack</code></h3>
|
||
<p>Pass this in to provide a set of routes to initially mount. This prop is required if <code>initialRoute</code> is not provided to the navigator. If this prop is not passed in, it will default internally to an array containing only <code>initialRoute</code>.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>[object]</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="navigationbar"></a><a href="#navigationbar" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>navigationBar</code></h3>
|
||
<p>Use this to provide an optional component representing a navigation bar that is persisted across scene transitions. This component will receive two props: navigator and navState representing the navigator component and its state. The component is re-rendered when the route changes.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>node</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="navigator"></a><a href="#navigator" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>navigator</code></h3>
|
||
<p>Optionally pass in the navigator object from a parent Navigator.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>object</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="ondidfocus"></a><a href="#ondidfocus" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>onDidFocus</code></h3>
|
||
<p>Will be called with the new route of each scene after the transition is complete or after the initial mounting.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>function</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="onwillfocus"></a><a href="#onwillfocus" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>onWillFocus</code></h3>
|
||
<p>Pass in a function to get notified with the target route when the navigator component is mounted and before each navigator transition.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>function</td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="renderscene"></a><a href="#renderscene" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>renderScene</code></h3>
|
||
<p>Required function which renders the scene for a given route. Will be invoked with the route and the navigator object.</p>
|
||
<pre><code class="hljs css language-javascript"><span class="token punctuation">(</span>route<span class="token punctuation">,</span> navigator<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
|
||
<span class="token operator"><</span>MySceneComponent title<span class="token operator">=</span><span class="token punctuation">{</span>route<span class="token punctuation">.</span>title<span class="token punctuation">}</span> navigator<span class="token operator">=</span><span class="token punctuation">{</span>navigator<span class="token punctuation">}</span> <span class="token operator">/</span><span class="token operator">></span>
|
||
<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>function</td><td>Yes</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="scenestyle"></a><a href="#scenestyle" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>sceneStyle</code></h3>
|
||
<p>Styles to apply to the container of each scene.</p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Type</th><th>Required</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td><a href="/react-native/docs/0.34/style">style</a></td><td>No</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<h2><a class="anchor" aria-hidden="true" id="methods-1"></a><a href="#methods-1" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Methods</h2>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="immediatelyresetroutestack"></a><a href="#immediatelyresetroutestack" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>immediatelyResetRouteStack()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">immediatelyResetRouteStack</span><span class="token punctuation">(</span><span class="token punctuation">(</span>nextRouteStack<span class="token punctuation">:</span> RouteStack<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Reset every scene with an array of routes. All existing route stacks are destroyed and potentially recreated. There is no accompanying animation and this method immediately replaces and re-renders the navigation bar and the stack items.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>nextRouteStack</td><td>RouteStack</td><td>Yes</td><td>Next route stack to reinitialize.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="jumpto"></a><a href="#jumpto" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>jumpTo()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">jumpTo</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Transition to an existing scene without unmounting.</p>
|
||
<p>The specified route must be in the currently mounted set of routes defined in <code>routeStack</code>.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes No</td><td>Route to transition to.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="jumpforward"></a><a href="#jumpforward" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>jumpForward()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">jumpForward</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Jump forward to the next scene in the route stack.</p>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="jumpback"></a><a href="#jumpback" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>jumpBack()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">jumpBack</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Jump backward without unmounting the current scene.</p>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="xxxx"></a><a href="#xxxx" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>XXXX()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Navigate forward to a new scene, squashing any scenes that you could jump forward to.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes No</td><td>Route to push into the navigator stack.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="pop"></a><a href="#pop" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>pop()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">popN</span><span class="token punctuation">(</span><span class="token punctuation">(</span>n<span class="token punctuation">:</span> number<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Go back N scenes at once. When N=1, behavior matches pop(). When N is invalid (negative or bigger than current routes count), do nothing.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>n</td><td>number</td><td>Yes</td><td>The number of scenes to pop. Should be an integer.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="pop-1"></a><a href="#pop-1" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>pop()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Transition back and unmount the current scene.</p>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="replaceatindex"></a><a href="#replaceatindex" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>replaceAtIndex()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">replaceAtIndex</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>index<span class="token punctuation">:</span> number<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>cb<span class="token punctuation">:</span> Function<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Replace a scene as specified by an index.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes</td><td>Route representing the new scene to render.</td></tr>
|
||
<tr><td>index</td><td>number</td><td>Yes</td><td>The route in the stack that should be replaced. If negative, it counts from the back of the stack.</td></tr>
|
||
<tr><td>cb</td><td>function</td><td>Yes</td><td>Callback function when the scene has been replaced.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="replace"></a><a href="#replace" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>replace()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">replace</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Replace the current scene with a new route.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes No</td><td>Route that replaces the current scene.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="replaceprevious"></a><a href="#replaceprevious" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>replacePrevious()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">replacePrevious</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Replace the previous scene.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes</td><td>Route that replaces the previous scene.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="poptotop"></a><a href="#poptotop" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>popToTop()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">popToTop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Pop to the first scene in the stack, unmounting every other scene.</p>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="poptoroute"></a><a href="#poptoroute" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>popToRoute()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">popToRoute</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Pop to a particular scene, as specified by its route. All scenes after it will be unmounted.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes</td><td>Route to pop to.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="replacepreviousandpopxxxx"></a><a href="#replacepreviousandpopxxxx" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>replacePreviousAndPopXXXX()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">replacePreviousAndPop</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Replace the previous scene and pop to it.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes</td><td>Route that replaces the previous scene.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="resetto"></a><a href="#resetto" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>resetTo()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">resetTo</span><span class="token punctuation">(</span><span class="token punctuation">(</span>route<span class="token punctuation">:</span> object<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Navigate to a new scene and reset route stack.</p>
|
||
<p><strong>Parameters:</strong></p>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>route</td><td>object</td><td>Yes</td><td>Route to navigate to.</td></tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<h3><a class="anchor" aria-hidden="true" id="getcurrentroutes"></a><a href="#getcurrentroutes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>getCurrentRoutes()</code></h3>
|
||
<pre><code class="hljs css language-javascript"><span class="token function">getCurrentRoutes</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
</code></pre>
|
||
<p>Returns the current list of routes.</p>
|
||
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/react-native/docs/0.34/modal"><span class="arrow-prev">← </span><span>Modal</span></a><a class="docs-next button" href="/react-native/docs/0.34/navigatorios"><span>Next</span><span class="arrow-next"> →</span></a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/react-native/" class="nav-home"><img src="/react-native/img/header_logo.png" alt="React Native" width="66" height="58"/></a><div><h5><a href="/react-native/docs/getting-started.html">Docs</a></h5><a href="/react-native/docs/getting-started.html">Getting Started</a><a href="/react-native/docs/tutorial.html">Tutorial</a><a href="/react-native/docs/components-and-apis.html">Components and APIs</a><a href="/react-native/docs/more-resources.html">More Resources</a></div><div><h5>Community</h5><a href="/react-native/help.html">The React Native Community</a><a href="/react-native/showcase.html">Who's using React Native?</a><a href="http://stackoverflow.com/questions/tagged/react-native" target="_blank">Ask Questions on Stack Overflow</a><a href="https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md">Contributor Guide</a></div><div><h5>More Resources</h5><a href="/react-native/blog/">Blog</a><a href="https://twitter.com/reactnative" target="_blank">Twitter</a><a href="https://github.com/facebook/react-native" target="_blank">GitHub</a><a href="http://reactjs.org" target="_blank">React</a></div></section><a href="https://code.facebook.com/projects/" target="_blank" class="fbOpenSource"><img src="/react-native/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright © 2019 Facebook Inc.</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.fbAsyncInit = function() {FB.init({appId:'1677033832619985',xfbml:true,version:'v2.7'});};(function(d, s, id){var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) {return;}js = d.createElement(s); js.id = id;js.src = '//connect.facebook.net/en_US/sdk.js';fjs.parentNode.insertBefore(js, fjs);}(document, 'script','facebook-jssdk'));
|
||
</script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
|
||
document.addEventListener('keyup', function(e) {
|
||
if (e.target !== document.body) {
|
||
return;
|
||
}
|
||
// keyCode for '/' (slash)
|
||
if (e.keyCode === 191) {
|
||
const search = document.getElementById('search_input_react');
|
||
search && search.focus();
|
||
}
|
||
});
|
||
</script><script>
|
||
var search = docsearch({
|
||
|
||
apiKey: '2c98749b4a1e588efec53b2acec13025',
|
||
indexName: 'react-native-versions',
|
||
inputSelector: '#search_input_react',
|
||
algoliaOptions: {"facetFilters":["tags:0.34"],"hitsPerPage":5}
|
||
});
|
||
</script></body></html> |