Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@flow
- import * as React from "react";
- import { BackHandler } from "react-native";
- import { connect } from "react-redux";
- import Login from "../components/Login";
- import LoginActions from "../store/actions/LoginActions";
- type Props = {
- login: Function
- };
- export class LoginScreen extends React.Component<Props> {
- props: Props;
- handleLogin: Function;
- backButtonSubscription: { remove: Function };
- constructor(props: Props) {
- super(props);
- this.handleLogin = this.handleLogin.bind(this);
- }
- componentDidMount() {
- this.backButtonSubscription = BackHandler.addEventListener(
- "hardwareBackPress",
- () => { return true; }
- );
- }
- componentWillUnmount() {
- this.backButtonSubscription.remove();
- }
- handleLogin(userName: string, password: string) {
- this.props.login(userName, password);
- }
- render() {
- return <Login handleLogin={this.handlelogin} />;
- }
- }
- const mapStateToProps = (state) => {
- return {
- errorMessage: state.login.errorMessage
- };
- };
- const mapDispatchToProps = dispatch => {
- return {
- login: (userName, password) => {
- dispatch(LoginActions.login(userName, password));
- }
- };
- };
- export default connect(mapStateToProps, mapDispatchToProps)(LoginScreen);
Add Comment
Please, Sign In to add comment