In our application, we used the library of icons, which was created by the first developers and was no longer supported by the new version of the react (16.0 and higher)
We decided to leave their previous look, just by slightly changing the code so that it worked, and to make it as a Component.
Here is how it look's now:
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import * as icons from 'icons';
class Icon extends Component {
static propTypes = {
type: PropTypes.oneOf(Object.keys(icons)).isRequired
};
render() {
const {type, ...other} = this.props;
const IconComponent = icons[type];
return IconComponent ? (
<IconComponent {...other}/>
) : null;
}
}
export * from '/icons';
export default Icon;
In theory, everything should work fine, since other components in this directory are written in a similar way.
But there is an error that I have never faced before:
00:14:58 App /home/cpt/Desktop/prod/local/app/components/Base/Elements/IconSocial/index.js:3
00:14:58 App import _Object$defineProperty from 'babel-runtime/core-js/object/define-property';
00:14:58 App ^^^^^^
00:14:58 App SyntaxError: Unexpected token import
Error points to this line: import * as icons from 'icons';
We use babel-core": "6.26.3"
Tell me, please, what could possibly be? Thanks in advance for any of your advice.