Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {Component} from 'react'
  2. import User from '../models/user.js'
  3.  
  4. module.exports = function attachUserToComponent (WrappedComponent) {
  5.   return class extends Component {
  6.     constructor (props) {
  7.       super(props)
  8.  
  9.       this.state = {
  10.         user: User.get(),
  11.         isLoggedIn: User.isLoggedIn()
  12.       }
  13.     }
  14.  
  15.     render () {
  16.       return <WrappedComponent user={this.state} {...this.props} />
  17.     }
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement