Skip to content

Commit

Permalink
Merge pull request #604 from mikefowler/cleanup-modal
Browse files Browse the repository at this point in the history
Cleanup Modal.js
  • Loading branch information
lelandrichardson committed Apr 27, 2016
2 parents e187567 + 9c0e667 commit 9f521d1
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/Modal.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import React, { Component, View } from 'react-native';
import React, {
PropTypes,
View,
} from 'react-native';
import DefaultRenderer from './DefaultRenderer';

export default class extends Component {
render() {
const children = this.props.navigationState.children;
const state = children[0];
return (<View style={{ flex:1 }}>
<DefaultRenderer navigationState={state} key={state.key} {...state} />
{children.length > 1 && children.map((el, i) => {
if (i > 0 && el.component) {
const Component = el.component;
return <Component key={el.key} {...el} />;
}
})}
</View>);
}
const propTypes = {
navigationState: PropTypes.shape({
children: PropTypes.array,
}),
};

export default function Modal(props: Object) {
const children = props.navigationState.children;
const state = children[0];

return (
<View style={{ flex: 1 }}>
<DefaultRenderer navigationState={state} key={state.key} {...state} />
{children.length > 1 && children.map((el, i) => {
if (i > 0 && el.component) {
const Component = el.component;
return <Component key={el.key} {...el} />;
}

return null;
})}
</View>
);
}

Modal.propTypes = propTypes;

0 comments on commit 9f521d1

Please sign in to comment.