mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
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:
committed by
Facebook Github Bot 2
parent
a7e5312aeb
commit
a28e59bd97
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user