mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Rename navigationState.children to navigationState.routes.
Summary: [Experimental API breaking changes] The notion of `parent` or `children` in navigaton is misleading. We have no intention to maintain or build the nested or hierarchical navigation states. To be clear, rename `navigationState.children` to `navigationState.route`. Reviewed By: ericvicenti Differential Revision: D3332115 fbshipit-source-id: c72ed08acaf030fb9c60abf22fb15cc0f44b3485
This commit is contained in:
committed by
Facebook Github Bot 2
parent
75d538e3eb
commit
1e626027f5
@@ -50,7 +50,7 @@ const ExampleReducer = NavigationReducer.StackReducer({
|
||||
initialState: {
|
||||
key: 'AnimatedExampleStackKey',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'First Route'},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ const ExampleReducer = NavigationReducer.StackReducer({
|
||||
initialState: {
|
||||
key: 'BasicExampleStackKey',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'First Route'},
|
||||
],
|
||||
},
|
||||
@@ -59,12 +59,12 @@ const NavigationBasicExample = React.createClass({
|
||||
return (
|
||||
<ScrollView style={styles.topView}>
|
||||
<NavigationExampleRow
|
||||
text={`Current page: ${this.state.children[this.state.index].key}`}
|
||||
text={`Current page: ${this.state.croutes[this.state.index].key}`}
|
||||
/>
|
||||
<NavigationExampleRow
|
||||
text={`Push page #${this.state.children.length}`}
|
||||
text={`Push page #${this.state.routes.length}`}
|
||||
onPress={() => {
|
||||
this._handleAction({ type: 'push', key: 'page #' + this.state.children.length });
|
||||
this._handleAction({ type: 'push', key: 'page #' + this.state.routes.length });
|
||||
}}
|
||||
/>
|
||||
<NavigationExampleRow
|
||||
|
||||
@@ -57,7 +57,7 @@ function createReducer(initialState) {
|
||||
const ExampleReducer = createReducer({
|
||||
index: 0,
|
||||
key: 'exmaple',
|
||||
children: [{key: 'First Route'}],
|
||||
routes: [{key: 'First Route'}],
|
||||
});
|
||||
|
||||
class NavigationCardStackExample extends React.Component {
|
||||
|
||||
@@ -106,7 +106,7 @@ const ExampleAppReducer = NavigationReducer.TabsReducer({
|
||||
initialState: {
|
||||
key: 'notifs',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'base', type: 'NotifsPage'},
|
||||
],
|
||||
},
|
||||
@@ -121,7 +121,7 @@ const ExampleAppReducer = NavigationReducer.TabsReducer({
|
||||
initialState: {
|
||||
key: 'settings',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'base', type: 'SettingsPage'},
|
||||
],
|
||||
},
|
||||
@@ -136,7 +136,7 @@ const ExampleAppReducer = NavigationReducer.TabsReducer({
|
||||
initialState: {
|
||||
key: 'profile',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'base', type: 'ProfilePage'},
|
||||
],
|
||||
},
|
||||
@@ -256,7 +256,7 @@ class NavigationCompositionExample extends React.Component {
|
||||
onNavigate={this.handleAction.bind(this)}
|
||||
/>
|
||||
<NavigationExampleTabBar
|
||||
tabs={this.state.children}
|
||||
tabs={this.state.routes}
|
||||
index={this.state.index}
|
||||
onNavigate={this.handleAction.bind(this)}
|
||||
/>
|
||||
@@ -284,7 +284,7 @@ class ExampleMainView extends React.Component {
|
||||
|
||||
_renderScene(): ReactElement {
|
||||
const {navigationState} = this.props;
|
||||
const childState = navigationState.children[navigationState.index];
|
||||
const childState = navigationState.routes[navigationState.index];
|
||||
return (
|
||||
<ExampleTabScreen
|
||||
key={'tab_screen' + childState.key}
|
||||
|
||||
@@ -78,13 +78,13 @@ class NavigationTabsExample extends React.Component {
|
||||
return (
|
||||
<View style={styles.topView}>
|
||||
<ExmpleTabPage
|
||||
tabs={this.state.children}
|
||||
tabs={this.state.routes}
|
||||
index={this.state.index}
|
||||
onExampleExit={this.props.onExampleExit}
|
||||
onNavigate={this.handleAction.bind(this)}
|
||||
/>
|
||||
<NavigationExampleTabBar
|
||||
tabs={this.state.children}
|
||||
tabs={this.state.routes}
|
||||
index={this.state.index}
|
||||
onNavigate={this.handleAction.bind(this)}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* 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.
|
||||
*
|
||||
* The examples provided by Facebook are for non-commercial testing and
|
||||
* evaluation purposes only.
|
||||
*
|
||||
@@ -39,7 +46,7 @@ export type UIExplorerNavigationState = {
|
||||
const UIExplorerStackReducer = StackReducer({
|
||||
getPushedReducerForAction: (action, lastState) => {
|
||||
if (action.type === 'UIExplorerExampleAction' && UIExplorerList.Modules[action.openExample]) {
|
||||
if (lastState.children.find(child => child.key === action.openExample)) {
|
||||
if (lastState.routes.find(route => route.key === action.openExample)) {
|
||||
// The example is already open, we should avoid pushing examples twice
|
||||
return null;
|
||||
}
|
||||
@@ -51,7 +58,7 @@ const UIExplorerStackReducer = StackReducer({
|
||||
initialState: {
|
||||
key: 'UIExplorerMainStack',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{key: 'AppList'},
|
||||
],
|
||||
},
|
||||
@@ -70,7 +77,7 @@ function UIExplorerNavigationReducer(lastState: ?UIExplorerNavigationState, acti
|
||||
stack: {
|
||||
key: 'UIExplorerMainStack',
|
||||
index: 0,
|
||||
children: [
|
||||
routes: [
|
||||
{
|
||||
key: 'AppList',
|
||||
filter: action.filter,
|
||||
|
||||
Reference in New Issue
Block a user