<" /> <" /> <"/>

How to use mui-x without nodejs?

16 views Asked by At

I have been able to use react and material-ui in the browser without nodejs. Example:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@latest/babel.min.js"></script>
    <script src="https://unpkg.com/@mui/material@latest/umd/material-ui.development.js"></script>
</head>

<body>
    <div id="root"></div>
    <script type="text/babel">
        const { Button } = MaterialUI;
        function App() { return (<Button>Hello World!</Button>); }
        ReactDOM.render(<App />, document.getElementById("root"));
    </script>
</body>

But what I'm really interested is in using the RichTreeView from mui-x, but it looks like that mui-x is not bundled:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@latest/babel.min.js"></script>
    <script src="https://unpkg.com/@mui/material@latest/umd/material-ui.development.js"></script>
</head>

<body>
    <div id="root"></div>
    <script type="text/babel">
        const { RichTreeView } = MaterialUI;
        function App() { return (<RichTreeView />); }
        ReactDOM.render(<App />, document.getElementById("root"));
    </script>
</body>

It fails with React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined..

So I wonder, is it possible to build my own standalone mui-x.js file that I can include locally? What I'm doing is not a website but more like a desktop app that runs in a browser; so I can live with installing any backend tools requires to create the "mui-x.js" bundle as far as I don't need any of those tools later.

Does that bundle exists somewhere already? Otherwise, how can I build my own?

0

There are 0 answers