Return statement missing for renderScene

Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?
Example code for "Using Navigators" under "THE BASICS" does not work. renderScene needs to return the components, not just instantiate them.

**Test plan (required)**

I copy-paste and ran the code but did not get anything rendered. I added a return statement before the component which made it work.

Arrow functions need a return statement when supplying a { block of code }.
Closes https://github.com/facebook/react-native/pull/9161

Differential Revision: D3663200

Pulled By: hramos

fbshipit-source-id: a8732dd1098de7c8ea915f459adb3403a8168f19
This commit is contained in:
Seph Soliman 2016-08-03 11:24:41 -07:00 committed by Facebook Github Bot 5
parent 54d8f221c2
commit 0fdbfb029e
1 changed files with 22 additions and 20 deletions

View File

@ -78,7 +78,7 @@ render() {
<Navigator <Navigator
initialRoute={{ title: 'My Initial Scene', index: 0 }} initialRoute={{ title: 'My Initial Scene', index: 0 }}
renderScene={(route, navigator) => { renderScene={(route, navigator) => {
<MyScene title={route.title} /> return <MyScene title={route.title} />
}} }}
/> />
); );
@ -112,25 +112,27 @@ export default class SimpleNavigationApp extends Component {
<Navigator <Navigator
initialRoute={{ title: 'My Initial Scene', index: 0 }} initialRoute={{ title: 'My Initial Scene', index: 0 }}
renderScene={(route, navigator) => renderScene={(route, navigator) =>
<MyScene return (
title={route.title} <MyScene
title={route.title}
// Function to call when a new scene should be displayed
onForward={ () => { // Function to call when a new scene should be displayed
const nextIndex = route.index + 1; onForward={ () => {
navigator.push({ const nextIndex = route.index + 1;
title: 'Scene ' + nextIndex, navigator.push({
index: nextIndex, title: 'Scene ' + nextIndex,
}); index: nextIndex,
}} });
}}
// Function to call to go back to the previous scene
onBack={() => { // Function to call to go back to the previous scene
if (route.index > 0) { onBack={() => {
navigator.pop(); if (route.index > 0) {
} navigator.pop();
}} }
/> }}
/>
)
} }
/> />
) )