import React from 'react'; import Typography from '@material-ui/core/Typography'; import { connect } from 'react-redux'; import { YOUR_CONTACT_CODE } from './constants'; import { checkAndDispatchStatusContactCode } from '../../actions/accounts'; const WrappedDisplayBox = ({ displayType, pubKey, getStatusContactCode }) => (
getStatusContactCode(displayType, pubKey)}>
{displayType}
{pubKey}
); const mapDispatchToDisplayBoxProps = dispatch => ({ getStatusContactCode(displayType, pubKey) { if (displayType === YOUR_CONTACT_CODE && !pubKey) checkAndDispatchStatusContactCode(dispatch); }, }); export default connect(null, mapDispatchToDisplayBoxProps)(WrappedDisplayBox);