From 126016862e5b6c92e69dcdf611a156711a6d4f80 Mon Sep 17 00:00:00 2001 From: phproot Date: Wed, 22 Jun 2016 22:59:06 +0800 Subject: [PATCH] tabs show onPress item (#828) * tabs show onPress item * [Fix] Fix sceneStyle layout dislocation DefaultRenderer * ESLINT * ESLINT * recovery this is not a good solution. * fix @alextkd * ESLINT --- src/Actions.js | 6 ++++-- src/TabBar.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Actions.js b/src/Actions.js index 88bb09cf6..de7a4eba6 100644 --- a/src/Actions.js +++ b/src/Actions.js @@ -116,7 +116,7 @@ class Actions { }); list = normalized; // normalize the list of scenes - const condition = el => (!el.props.component && !el.props.children && + const condition = el => (!el.props.component && !el.props.children && !el.props.onPress && (!el.props.type || el.props.type === REFRESH_ACTION)); // determine sub-states let baseKey = root.key; @@ -126,7 +126,9 @@ class Actions { if (list.length) { res.children = list.map(c => this.iterate(c, res, refs, wrapBy).key); } else { - assert(component, `component property is not set for key=${key}`); + if (!staticProps.onPress) { + assert(component, `component property is not set for key=${key}`); + } // wrap scene if parent is "tabs" if (parentProps.tabs) { const innerKey = `${res.key}_`; diff --git a/src/TabBar.js b/src/TabBar.js index ae1740bfc..017496a9f 100644 --- a/src/TabBar.js +++ b/src/TabBar.js @@ -25,7 +25,11 @@ class TabBar extends Component { `No action is defined for name=${el.props.name} ` + `actions: ${JSON.stringify(Object.keys(Actions))}`); } - Actions[el.props.name](); + if (typeof el.props.onPress === 'function') { + el.props.onPress(); + } else { + Actions[el.props.name](); + } } renderScene(navigationState) {