Skip to content

Import error with Material UI (X) components #1464

Answered by mbostock
rhenkin asked this question in Q&A
Discussion options

You must be logged in to vote

It still doesn’t work, but the recommended way to do this now would be to use npm: imports instead of node imports. (When we support a configurable React engine #1465 then you could switch to node imports.) When using npm: imports, you don’t need to install anything, and the example code would look like this:

import Box from "npm:@mui/material/Box";
import {SimpleTreeView} from "npm:@mui/x-tree-view/SimpleTreeView";
import {TreeItem} from "npm:@mui/x-tree-view/TreeItem";

function FirstComponent() {
  return (
    <Box sx={{ minHeight: 352, minWidth: 250 }}>
      <SimpleTreeView>
        <TreeItem itemId="grid" label="Data Grid">
          <TreeItem itemId="grid-community" label="@mui/x-…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@mbostock
Comment options

Comment options

You must be logged in to vote
2 replies
@rhenkin
Comment options

@mbostock
Comment options

Answer selected by rhenkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants