Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import React, { Component } from 'react'
  2.  
  3. const withAuth = (EnhancedComponent) => {
  4.  
  5. return class extends Component {
  6. constructor(props) {
  7. super(props)
  8. this.state = {
  9. authenticated: false
  10. }
  11. }
  12.  
  13. componentDidMount() {
  14. console.log('console logging from withAuth')
  15. }
  16. render() {
  17. return (
  18. <EnhancedComponent
  19. loggedIn]{this.state.loggedIn}
  20. {...this.props}
  21. />)
  22. }
  23.  
  24. }
  25.  
  26. }
  27.  
  28. export default withAuth
  29.  
  30. // to use this, we need to setup a new action in our auth_controller (with action auth#check)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement