I have 2 repos:
- my main web app
- my shared component library, being imported as a node module through package.json
Both of them use React. In my main web app, I'm just importing the component files of my shared component library directly like so:
Switch.js (in my shared component library)
import React from 'react';
import { Switch } from 'antd';
import styled from 'styled-components';
import { CloseOutlined, CheckOutlined } from '@ant-design/icons';
const StyledSwitch = styled(Switch).attrs({
checkedChildren: <CheckOutlined />,
unCheckedChildren: <CloseOutlined />
})``;
export default StyledSwitch;
My main web app:
import Switch from 'my-shared-component-lib/components/Switch';
However, I'm getting this error:
../my-shared-component-lib/components/Switch.js
SyntaxError: /Users/edmundmai/Documents/src/my-shared-component-lib/components/Switch.js: Unexpected token (9:19)
7 |
8 | const StyledSwitch = styled(Switch).attrs({
> 9 | checkedChildren: <CheckOutlined />,
| ^
10 | unCheckedChildren: <CloseOutlined />
11 | })`
12 | &.ant-switch {
Is there something I have to install so that my imports will work?