question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'Component' of undefined

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.7.3

Environment

Windows 10, Chrome (latest version)

Reproduction link

https://stackoverflow.com/questions/51593464/cannot-read-property-component-of-undefined

Steps to reproduce

Whenever I wanna use an Ant design Component I catch an error with this title:

antd.min.js:23 Uncaught TypeError: Cannot read property 'Component' of undefined
    at Object.<anonymous> (antd.min.js:23)
    at t (antd.min.js:7)
    at Object.<anonymous> (antd.min.js:31)
    at t (antd.min.js:7)
    at Object.<anonymous> (antd.min.js:50)
    at t (antd.min.js:7)
    at Object.<anonymous> (antd.min.js:7)
    at t (antd.min.js:7)
    at antd.min.js:7
    at antd.min.js:7

I use the latest version (3.7.3)

In this part I’ve used Layout Component of ant design:

import React, {Component} from 'react';

import ReactDOM from 'react-dom';
    
import { Layout, Menu, Icon } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

ReactDOM.render(
  <Layout>
    <Sider
      breakpoint="lg"
      collapsedWidth="0"
      onBreakpoint={(broken) => { console.log(broken); }}
      onCollapse={(collapsed, type) => { console.log(collapsed, type); }}
    >
      <div className="logo" />
      <Menu theme="dark" mode="inline" defaultSelectedKeys={['4']}>
        <Menu.Item key="1">
          <Icon type="user" />
          <span className="nav-text">nav 1</span>
        </Menu.Item>
        <Menu.Item key="2">
          <Icon type="video-camera" />
          <span className="nav-text">nav 2</span>
        </Menu.Item>
        <Menu.Item key="3">
          <Icon type="upload" />
          <span className="nav-text">nav 3</span>
        </Menu.Item>
        <Menu.Item key="4">
          <Icon type="user" />
          <span className="nav-text">nav 4</span>
        </Menu.Item>
      </Menu>
    </Sider>
    <Layout>
      <Header style={{ background: '#fff', padding: 0 }} />
      <Content style={{ margin: '24px 16px 0' }}>
        <div style={{ padding: 24, background: '#fff', minHeight: 360 }}>
          content
        </div>
      </Content>
      <Footer style={{ textAlign: 'center' }}>
        Ant Design ©2018 Created by Ant UED
      </Footer>
    </Layout>
  </Layout>,
  document.getElementById('main'));

but I unfortunately face with error, while I just copied the antdesign code. I don’t know what is the problem, please help me.

What is expected?

The code works like it seems in the website.

What is actually happening?

antd.min.js:23 Uncaught TypeError: Cannot read property ‘Component’ of undefined at Object.<anonymous> (antd.min.js:23) at t (antd.min.js:7) at Object.<anonymous> (antd.min.js:31) at t (antd.min.js:7) at Object.<anonymous> (antd.min.js:50) at t (antd.min.js:7) at Object.<anonymous> (antd.min.js:7) at t (antd.min.js:7) at antd.min.js:7 at antd.min.js:7

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
ztplzcommented, Mar 28, 2019

@wilkog You should wrap element in Menu.Item. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'Component' of undefined - Stack Overflow
A bit late to this, but this sounds like a typescript error. If anyone else comes across this change import React, {Component} from...
Read more >
TypeError: Cannot read property 'Component' of undefined ...
I am using the cloudinary-react library and have run into the following error message when I add the Image component to my project:...
Read more >
How to Read React Errors (fix 'Cannot read property of ...
This error usually means you're trying to use .map on an array, but that array isn't defined yet. That's often because the array...
Read more >
TypeError: Cannot read property 'components' of undefined
When trying to import the mixin occurs the following problem Error in render: "TypeError: Cannot read property 'components' of undefined" But there is ......
Read more >
cannot read properties of undefined (reading 'component')
The problem is that as an Input variable, the reminders object is initially undefined until angular has finished initializing the component. See this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found