CountryName.tsx 478 Bytes
Newer Older
Maksym Tishchenko's avatar
Maksym Tishchenko committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React from 'react';
import { connect } from 'react-redux';

interface ICountryCode extends React.FunctionComponent {
  code3: string;
  countryCodes: Record<string, string>;
}

const countryCode = (props: ICountryCode) => {
  return props.countryCodes && props.countryCodes[props.code3] || null;
}

const mapStateToProps = (state) => ({
  countryCodes: state.decoding.countryCodes,
});

const CountryName = connect(mapStateToProps)(countryCode);

export { CountryName };