Created
May 20, 2020 11:23
-
-
Save alexroan/82456aba2b5131e88094a921519f382b to your computer and use it in GitHub Desktop.
Login.js
This file contains hidden or 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
import React, {Component} from 'react'; | |
import {connect} from 'react-redux'; | |
import {Container, Row, Col, Button, Alert} from 'react-bootstrap'; | |
import { loadWeb3 } from './redux/interactions'; | |
import FadeIn from 'react-fade-in'; | |
import { loggingInErrorSelector, loggingInSelector } from './redux/selectors'; | |
class Login extends Component { | |
render() { | |
const {dispatch, loggingIn, loggingInError} = this.props; | |
const login = async (e) => { | |
e.preventDefault(); | |
await loadWeb3(dispatch); | |
} | |
return ( | |
<FadeIn> | |
<Container> | |
<Row> | |
<Col className="text-center"> | |
<Button onClick={login}> | |
Connect | |
</Button> | |
{loggingInError !== false && loggingIn === false ? <FadeIn><Alert className="my-2" variant="danger">Connect to wallet failure: {loggingInError.message}</Alert></FadeIn> : <></>} | |
</Col> | |
</Row> | |
</Container> | |
</FadeIn> | |
); | |
} | |
} | |
function mapStateToProps(state){ | |
return { | |
loggingInError: loggingInErrorSelector(state), | |
loggingIn: loggingInSelector(state) | |
} | |
} | |
export default connect(mapStateToProps)(Login); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment