reactjsmeteornpmantdmeteor-react

Importing Ant Design Component doesn't work


I'm shocked over this problem I'm currently having right now. All my logic literally stopped. Something started not working, without me having changed anything. I mean I even have it on production, the identical code, but locally it started not working, out of nothing. Even when I go back to previous commits, that I'm 100% sure was working, it doesn't work.

Meteor, React, Ant-Design. Please help!

The error is: ReferenceError: Layout is not defined

Code is:

import React from 'react';
import Blaze from 'meteor/gadicc:blaze-react-component';
import { Link } from 'react-router-dom';
import { Layout, Menu } from 'antd';
const { Header, Content, Footer } = Layout;

class LayoutContainer extends React.Component {
  render() {

    const { match, children } = this.props;
    const pathname = match.location.pathname;

    return (
      <Layout className="layout">
        <Header style={{backgroundColor: '#fff'}}>
          <Menu
            selectedKeys={[pathname]}
            mode="horizontal"
            style={{ lineHeight: '64px', float: 'right' }}
          >
            <Menu.Item key={'/'}>
              <Link to="/">Home</Link>
            </Menu.Item>
            <Menu.Item key={'/create-a-gathering'}>
              <Link to="/create-a-gathering">Create</Link>
            </Menu.Item>
          </Menu>
          <div className="logo" />
          <Blaze template="loginButtons" />
        </Header>
        <Content style={{ marginTop: 20 }}>
          {children}
        </Content>
        <Footer style={{ textAlign: 'center' }}>

        </Footer>
      </Layout>
    )
  }
}

export default LayoutContainer;

Solution

  • I should have answered this long time ago, but here it goes:

    As Afaq Ahmed Khan pointed out (that too) :

    import { Layout, Menu } from 'antd/lib';
    

    is the answer.

    I guess babel in two packages conflict with each other and thus '/lib' to root '/' alias doesn't work.