Recommand · May 31, 2021 0

Node JS react Uncaught ReferenceError: Cannot access 'Hello' before initialization

Get "Uncaught ReferenceError: Cannot access ‘Hello’ before initialization" error in a simple component class, and cannot figure out why, please advise.

import * as React from 'react';
import styled, {css} from 'react-emotion';

const StyledDiv = styled('div')`
  color: red;
`;

export default class Hello extends React.Component {
  render() {
    return (
      <Container>
        <div>
          <h1>Hello</h1>
        </div>
      </Container>
    );
  }
}

the error is gone if I remove

 const StyledDiv = styled('div')`
  color: red;
`;