How to correctly configure package dependancy for microfrontends using webpack and react?

I have project with microfrontend using react and webpack. In the container app also I am using antd library. Then I created the microfrontend app and used as remoteEntry in container app. I was able to load the components successfully from the remote microfrontend to the container app.But when I try to install antd libry seperatly in the remote microfrontend and use it was giving me the following error.

    ERROR
null is not an object (evaluating 'dispatcher.useContext')
useContext@
Badge@
renderWithHooks@
updateForwardRef@
beginWork$1@
performUnitOfWork@
workLoopSync@
renderRootSync@
recoverFromConcurrentError@
performConcurrentWorkOnRoot@
workLoop@
flushWork@
performWorkUntilDeadline@

This is my remote microfrontend compoenent webpack config file.

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { ModuleFederationPlugin } = require('webpack').container;

module.exports = {
    mode: 'development',
    entry: path.resolve(__dirname, '../src', 'index.js'),
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
    },
    plugins: [
        new ModuleFederationPlugin({
          name:'ecom',
          filename:'remoteEntry.js',
          exposes:{
            './com1':'./src/pages/Com1',
            './com2':'./src/pages/Com2'
          }
        }),
        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, '../public', 'index.html'),
        }),
    ],
    module: {
        rules: [
            {
                test: /.(js|jsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env', '@babel/preset-react'],
                    },
                },
            },
            {
                test: /.css$/,
                use: ['style-loader', 'css-loader'],
            },
        ],
    },
    devServer: {
        static: {
            directory: path.join(__dirname, '../public'),
        },
        port: 3001,
    },
};

This is my container webpack config js file.

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { ModuleFederationPlugin } = require('webpack').container;

module.exports = {
    mode: 'development',
    entry: path.resolve(__dirname, '../src', 'index.js'),
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
    },
    plugins: [
        new ModuleFederationPlugin({
            name:'container',
            remotes:{
                chart: 'ecom@http://localhost:3001/remoteEntry.js'
            }
        }),
        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, '../public', 'index.html'),
        }),
    ],
    module: {
        rules: [
            {
                test: /.(js|jsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env', '@babel/preset-react'],
                    },
                },
            },
            {
                test: /.css$/,
                use: ['style-loader', 'css-loader'],
            },
            {
                test: /.(png|jpe?g|gif)$/i,
                use: [
                  {
                    loader: 'file-loader',
                  },
                ],
              },
        ],
    },
    devServer: {
        static: {
            directory: path.join(__dirname, '../public'),
        },
        port: 3000,
    },
};

This is how I used the compoenent from remote in the container app.

import React, { Suspense } from "react";
import { Responsive, WidthProvider } from "react-grid-layout";
import { Image, Empty } from 'antd'
import picon from '../../assets/images/performance-icon-png-19.png'
import chartStyle from "./ChartsStyle";
import { connect } from 'react-redux'
import { emptyCompanyMsg } from "../../constants";
const Com1 = React.lazy(() => import('ecom/Com1'))
const Com2 = React.lazy(() => import('ecom/Com2'))

const ResponsiveGridLayout = WidthProvider(Responsive);

const Ecom = (props) => {
  const { company } = props
  const layout = {
    lg: [
      { x: 0, y: 0, w: 1, h: 2 },
      { x: 6, y: 1, w: 1, h: 2 }
    ],
    md: [
      { x: 0, y: 0, w: 1, h: 2 },
      { x: 0, y: 1, w: 1, h: 2 }
    ],
    sm: [
      { x: 0, y: 0, w: 1, h: 2 },
      { x: 0, y: 1, w: 1, h: 2 }
    ],
    xs: [
      { x: 0, y: 0, w: 1, h: 2 },
      { x: 0, y: 1, w: 1, h: 2 }
    ],
    xxs: [
      { x: 0, y: 0, w: 1, h: 2 },
      { x: 0, y: 1, w: 1, h: 2 }
    ],
  }

  return (
    <div style={chartStyle.chartsOuter}>
      <div style={chartStyle.chartTitle}>
        <Image src={picon} width={30} height={30} />
        Performance
      </div>
      <Suspense fallback={"loading"}>
        {company ? <ResponsiveGridLayout
          className="chart-layout"
          layouts={layout}
          cols={{ lg: 2, md: 1, sm: 1, xs: 1, xxs: 1 }}
          width={1200}
          breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
          rowHeight={500}
          preventCollision={false}
        >
          <div key="1" >
            <Com1 />
          </div>
          <div key="2">
            <Com2 />
          </div>
        </ResponsiveGridLayout> : <Empty description={emptyCompanyMsg} />}
      </Suspense>
    </div>
  );
}

const mapStateToProps = state => {
  return {
    company: state.company.company
  }
}


export default connect(mapStateToProps, {})(Ecom);

This is my remote compoenet look likes.

import React from "react";
import ChartCard from "../../components/ChartCard/ChartCard.component";

    const Com1 = () => {
        return (
            <>
                <ChartCard />
            </>
        )
    }
    
    export default Com1


    import React from "react";
    import { Badge } from 'antd';
    
    const ChartCard = (props) => {
        return (
            // <Card title="test" >
            //     testing
            // </Card>
            <Badge />
        )
    }
    
    export default ChartCard;

Can someone help to resolve this issue. I search and tried the solutions provided inthe internet still unable to use andt liabry in the remote microfrontend.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật