Skip to content

Commit

Permalink
closes Remeic#9 - copy email to clipboard when page first renders
Browse files Browse the repository at this point in the history
componentDidMount excutes once, after the page has rendered successfully.
  • Loading branch information
ThomasNolte committed Oct 30, 2018
1 parent 66bbd66 commit b68521f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class Mail extends Component {
this.notify();
};

componentDidMount = () => {
navigator.clipboard.writeText(document.getElementById('email').value)
.then(() => {
this.notify();
})
.catch((err) => {
console.error('could not copy to clipboard ', err);
});
}

render() {
return (
<div>
Expand Down

0 comments on commit b68521f

Please sign in to comment.