I am developing application using create-react-app, and using third party module which is not compile, I am including JSX file from this to my project.
getting following error when start or build
******.jsx
Module parse failed: Unexpected token (12:25)
You may need an appropriate loader to handle this file type.
My react application is not eject and don't want to eject.
I don't want to eject from react-script
Sample code
Link.jsx
in Library
import React from 'react';
import { string } from 'prop-types';
import './Link.scss';
const STATUS = {
HOVERED: 'hovered',
NORMAL: 'normal',
};
class Link extends React.Component {
constructor(props) {
super(props);
this.onMouseEnter = this.onMouseEnter.bind(this);
this.onMouseLeave = this.onMouseLeave.bind(this);
this.state = {
className: STATUS.NORMAL,
};
}
onMouseEnter() {
this.setState({ className: STATUS.HOVERED });
}
onMouseLeave() {
this.setState({ className: STATUS.NORMAL });
}
render() {
const { className } = this.state;
const { page, children } = this.props;
return (
<a
className={className}
href={page}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
>
{children}
</a>
);
}
}
Link.propTypes = {
page: string,
children: string,
};
Link.defaultProps = {
page: '#',
children: '',
};
export default Link;
Above code is publish to internal npm repo and used in application
App.jsx
in application
import { Link} from '@myScope/myreactlib/Link'; // loaded from node_modules
App.jsx give error