@teikei/map
Version:
Teikei map SPA component. Teikei is the software that powers ernte-teilen.org, a website that maps out Community-supported Agriculture in Germany.
29 lines (24 loc) • 756 B
JavaScript
import React, { Component } from 'react'
import connect from 'react-redux/es/connect/connect'
import Loading from './components/Loading'
import { authenticateUser } from './containers/UserOnboarding/duck'
const withAuthentication = WrappedComponent => {
class AuthenticatorComponent extends Component {
componentDidMount() {
const { authenticateUser } = this.props
authenticateUser()
}
render() {
return this.props.authenticated ? (
<WrappedComponent {...this.props} />
) : (
<Loading />
)
}
}
return connect(
({ user }) => ({ authenticated: user.authenticated }),
{ authenticateUser: () => authenticateUser() }
)(AuthenticatorComponent)
}
export default withAuthentication