aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages/metamask-route.js
blob: 23c5b519993dedd1ef3a8f877adf066aa2426892 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const { connect } = require('react-redux')
const PropTypes = require('prop-types')
const { Route } = require('react-router-dom')
const h = require('react-hyperscript')

const MetamaskRoute = ({ component, mascaraComponent, isMascara, ...props }) => {
  return (
    h(Route, {
      ...props,
      component: isMascara && mascaraComponent ? mascaraComponent : component,
    })
  )
}

MetamaskRoute.propTypes = {
  component: PropTypes.func,
  mascaraComponent: PropTypes.func,
  isMascara: PropTypes.bool,
}

const mapStateToProps = state => {
  const { metamask: { isMascara } } = state
  return {
    isMascara,
  }
}

module.exports = connect(mapStateToProps)(MetamaskRoute)