mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 17:33:21 +08:00
Summary: This is the first step to clarify and simplify the type definations about navigation state. For now, `NavigationParentState` is actually used as the real navigation state and `NavigationState` is used as a route in navigation, which has been confusion among the APIs. To be clear, our APIs has no intention and interest in dealing with nested or hierarchical navigation states, and we should avoid have the name like `ParentState` or `children`. To fully migrate the types, theer will be a lot of code changes and this is just the first step to rename. = What's Next? 1. rename `navigationState.children` to `navigationState.routes` (breaking change!) 2. remove `navigationState.key` from its type defination. Reviewed By: ericvicenti Differential Revision: D3321403 fbshipit-source-id: 3e39b60f736c1135bc85d8bf2b89027d665e28d4
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* Facebook reserves all rights not expressly granted.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
// $FlowFixMe : This is a platform-forked component, and flow seems to only run on iOS?
|
|
const UIExplorerList = require('./UIExplorerList');
|
|
|
|
import type {NavigationRoute} from 'NavigationTypeDefinition';
|
|
|
|
function StateTitleMap(state: NavigationRoute): string {
|
|
if (UIExplorerList.Modules[state.key]) {
|
|
return UIExplorerList.Modules[state.key].title
|
|
}
|
|
if (state.key === 'AppList') {
|
|
return 'UIExplorer';
|
|
}
|
|
return 'Unknown';
|
|
}
|
|
|
|
module.exports = StateTitleMap;
|