Description
Description
I'm using Material-UI and the makeStyles
hook to style my application. Everything is working fine when the makeStyles
call is in the same file I'll be using it's output. When I place this call in a different file and import the result, RHL breaks.
For instance, take this Application.tsx
file:
import React from 'react';
import { hot } from 'react-hot-loader';
import Container from '@material-ui/core/Container';
import CssBaseline from '@material-ui/core/CssBaseline';
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
interface Props {
name: string;
}
const useStyles = makeStyles(theme => ({
container: {
marginTop: theme.spacing(8)
},
paper: {
padding: theme.spacing(3, 2)
}
}));
function Application(props: Props): JSX.Element {
const classes = useStyles();
const { name } = props;
return (
<React.Fragment>
<CssBaseline />
<Container className={classes.container} maxWidth="md">
<Paper className={classes.paper}>
<Typography variant="h5" component="p" align="center">
{'Hello there '}
<span role="img" aria-label="Waving Hand">
👋
</span>
{`, ${name}`}
</Typography>
</Paper>
</Container>
</React.Fragment>
);
}
export default hot(module)(Application);
Note: As you can see I'm using TypeScript with React.
The example above works just fine with RHL, no issues whatsoever.
But now I've changed Application.tsx
to this:
import React from 'react';
import { hot } from 'react-hot-loader';
import Container from '@material-ui/core/Container';
import CssBaseline from '@material-ui/core/CssBaseline';
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
import { useStyles } from './Application.styles';
interface Props {
name: string;
}
function Application(props: Props): JSX.Element {
const classes = useStyles();
const { name } = props;
return (
<React.Fragment>
<CssBaseline />
<Container className={classes.container} maxWidth="md">
<Paper className={classes.paper}>
<Typography variant="h5" component="p" align="center">
{'Hello there '}
<span role="img" aria-label="Waving Hand">
👋
</span>
{`, ${name}`}
</Typography>
</Paper>
</Container>
</React.Fragment>
);
}
export default hot(module)(Application);
And Application.styles.ts
:
import { makeStyles } from '@material-ui/core/styles';
export const useStyles = makeStyles(theme => ({
container: {
marginTop: theme.spacing(8),
},
paper: {
padding: theme.spacing(3, 2),
},
}));
Expected behavior
What you think should happen:
When saving Application.tsx
file, RHL should work as expected and without any errors.
Actual behavior
What actually happens:
When saving Application.tsx
file, RHL shows this error:
Environment
React Hot Loader version: v4.12.0
Run these commands in the project folder and fill in their results:
node -v
: v10.15.0yarn -v
: v1.16.0
Then, specify:
- Operating system: Windows 10 (WSL)
- Browser and version: Firefox Quantum 68.0b14 (64-bit)
Reproducible Demo
I apologize in advanced for not having a demo project yet. If one is really necessary, please let me know and I'll get it pushed as soon as I'm able to.