Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

MantineProvider was not found in component tree error #1

@AnnMarieW

Description

@AnnMarieW

Why this error happens:

dmc.MantineProvider wraps children in the @mantine/core context.

If your component is compiled with its own copy of Mantine (from node_modules), it’s asking a different context object.

React treats those contexts as completely separate — so it says MantineProvider was not found.

How to fix:

You need to make sure both dmc and your custom component resolve Mantine from the same place:

  1. In your custom component’s package.json, mark Mantine as a peer dependency, not a regular dependency:
{
  "peerDependencies": {
    "@mantine/core": "^8.0.0",
    "@mantine/hooks": "^8.0.0",    
  }
}

This way, it won’t bundle its own copy of Mantine.

  1. update webpack.config.js to mark it as external as well:
const externals = {
        react: {
            commonjs: 'react',
            commonjs2: 'react',
            amd: 'react',
            umd: 'react',
            root: 'React',
        },
        'react-dom': {
            commonjs: 'react-dom',
            commonjs2: 'react-dom',
            amd: 'react-dom',
            umd: 'react-dom',
            root: 'ReactDOM',
        },
        '@mantine/core': {
            commonjs: '@mantine/core',
            commonjs2: '@mantine/core',
            amd: '@mantine/core',
            umd: '@mantine/core',
        },
        '@mantine/hooks': {
            commonjs: '@mantine/hooks',
            commonjs2: '@mantine/hooks',
            amd: '@mantine/hooks',
            umd: '@mantine/hooks',
        },
    };

You will see the build size is much much smaller now too:

asset many_select.js 2.91 KiB [emitted] [minimized] (name: main)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions