move propTypes, defaultProps, and childContextTypes into class.

Summary: This will make the code more readable.

Reviewed By: ericvicenti

Differential Revision: D3096663

fb-gh-sync-id: 540d2107ea3cd4c60aabdf7a6503c8c22bc4a985
fbshipit-source-id: 540d2107ea3cd4c60aabdf7a6503c8c22bc4a985
This commit is contained in:
Hedger Wang
2016-03-28 16:45:18 -07:00
committed by Facebook Github Bot 2
parent a7e5312aeb
commit a28e59bd97
4 changed files with 82 additions and 77 deletions

View File

@@ -44,28 +44,18 @@ type State = {
const {PropTypes} = React;
const propTypes = {
applyAnimation: PropTypes.func,
navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
renderOverlay: PropTypes.func,
renderScene: PropTypes.func.isRequired,
};
const defaultProps = {
applyAnimation: (
position: NavigationAnimatedValue,
navigationState: NavigationParentState,
) => {
Animated.spring(
position,
{
bounciness: 0,
toValue: navigationState.index,
}
).start();
},
};
function applyDefaultAnimation(
position: NavigationAnimatedValue,
navigationState: NavigationParentState,
): void {
Animated.spring(
position,
{
bounciness: 0,
toValue: navigationState.index,
}
).start();
}
class NavigationAnimatedView
extends React.Component<any, Props, State> {
@@ -78,6 +68,18 @@ class NavigationAnimatedView
props: Props;
state: State;
static propTypes = {
applyAnimation: PropTypes.func,
navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
renderOverlay: PropTypes.func,
renderScene: PropTypes.func.isRequired,
};
static defaultProps = {
applyAnimation: applyDefaultAnimation,
};
constructor(props: Props, context: any) {
super(props, context);
@@ -233,9 +235,6 @@ const styles = StyleSheet.create({
},
});
NavigationAnimatedView.propTypes = propTypes;
NavigationAnimatedView.defaultProps = defaultProps;
NavigationAnimatedView = NavigationContainer.create(NavigationAnimatedView);
module.exports = NavigationAnimatedView;