-
Notifications
You must be signed in to change notification settings - Fork 121
/
SplashScreen.tsx
33 lines (26 loc) · 1.02 KB
/
SplashScreen.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from 'react';
import { NavigationSwitchScreenProps } from 'react-navigation';
import { connect } from 'react-redux';
import ScreenWrapper from '../components/ScreenWrapper';
import { userSelector } from '../redux/auth/selectors';
import { RootState } from '../redux/types';
import { routeNames } from '../routes/routeNames';
/* ------------- Props and State ------------- */
type ReduxProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps;
type Props = NavigationSwitchScreenProps<{}> & ReduxProps;
/* ------------- Component ------------- */
class Splash extends React.Component<Props> {
componentDidMount() {
const { user, navigation } = this.props;
const routeName = user ? routeNames.HomeStack : routeNames.AuthStack;
navigation.navigate(routeName);
}
render() {
return <ScreenWrapper />;
}
}
const mapStateToProps = (state: RootState) => ({
user: userSelector(state),
});
const mapDispatchToProps = {};
export default connect(mapStateToProps, mapDispatchToProps)(Splash);