Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[actions]: add support when dealing Scenes defined using array map #793

Merged
merged 2 commits into from
Jun 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Actions {
assert(key, 'unique key should be defined ');
assert(
reservedKeys.indexOf(key) === -1,
`'${key}' is not allowed as key name. Reserved keys: [${reservedKeys.join(', ')}]`,
`'${key}' is not allowed as key name. Reserved keys: [${reservedKeys.join(', ')}]`
);
const { children, component, ...staticProps } = root.props;
let type = root.props.type || (parentProps.tabs ? JUMP_ACTION : PUSH_ACTION);
Expand Down Expand Up @@ -97,9 +97,21 @@ class Actions {
...componentProps,
};
let list = children || [];
const normalized = [];
if (!(list instanceof Array)) {
list = [list];
}
list.forEach(item => {
if (item instanceof Array) {
item.forEach(it => {
normalized.push(it);
});
} else {
normalized.push(item);
}
});
list = normalized; // normalize the list of scenes

const condition = el => (!el.props.component && !el.props.children &&
(!el.props.type || el.props.type === REFRESH_ACTION));
// determine sub-states
Expand Down