-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #604 from mikefowler/cleanup-modal
Cleanup Modal.js
- Loading branch information
Showing
1 changed file
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |