web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Import Web Resource (html/react) with multiple scripts files (WITHOUT NODE.JS)

(0) ShareShare
ReportReport
Posted on by 110

FIRST, I need to know how to import a Web Resoruce (html with react.js) WITHOUT USING NODE.JS! then... I want to create a solution with a Web Resource (an html file with react.js) with multiple scripts linked to it, I have no Idea how to do it, ¿can someone give me a simple example? I CAN'T USE NODE.JS or any other thing, just the html with react, and I need to put the scripts files in it.

This is my code (doesn't work): 

<!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">
    <link rel="icon" type="image/png" href="src/reactFavicon.png">
    <link href="">fonts.googleapis.com/css rel="stylesheet">
    <title>Users</title>
    <script type="application/javascript" src="">unpkg.com/.../react.production.min.js"></script>
    <script type="application/javascript" src="">unpkg.com/.../react-dom.production.min.js"></script>
    <script type="application/javascript" src="">unpkg.com/.../babel.js"></script>
</head>
<body>
    <div id="root"></div>
    <script type="text/javascript" src="users.js">
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
This is the users.js script:
        const rootElement = document.getElementById('root')

        class Users extends React.Component {
            constructor(props) {
                super(props)
                this.state = {
                    items:[],
                    isLoaded: false
                }
            }

            componentDidMount() {
                fetch('jsonplaceholder.typicode.com/users')
                .then(res => res.json())
                .then(json => {
                    this.setState({
                    isLoaded: true,
                    items: json
                })
                })
            }

            render() {
                const title = this.props.title;
                var {isLoadeditems} = this.state;
                if(!isLoaded) {
                    return <div>Loading...</div>
                } else {
                    return(
                        <div class="Users">
                            {title}
                            <ul>
                                {items.map(item => (
                                    <li key={item.id}>
                                        {item.name} | {item.email} ||| lives in {item.address.street}{item.address.suite} ({item.address.city}), his/her phone number is {item.phone} and works in <strong>{item.company.name}</strong>.
                                    </li>
                                )) }
                            </ul>
                        </div>
                    )
                }
            }
        }
 
        function App() {
            return (
                <div>
                <Users 
                    title = "Users"
                />
                </div>
            )
        }

        ReactDOM.render(
            <App />,
            rootElement
        )
--------------------------------------------------------------------------------------------------------------------
If someone can really help me with this, I'll be really thankful (the code is just an example, it can be any other thing you want, just keep it simple). 
I have the same question (0)
  • Tiffastic Profile Picture
    on at
    RE: Import Web Resource (html/react) with multiple scripts files (WITHOUT NODE.JS)

    Thank you so much Clofly, I needed to add React code to our Dynamics app and I was scouring the web to do so.  Your post gave me guidance on how to accomplish this.

  • cloflyMao Profile Picture
    25,210 on at
    RE: Import Web Resource (html/react) with multiple scripts files (WITHOUT NODE.JS)

    Hi Partner,

    It seems that your example is modified based on the following link?

    https://dev.to/luispa/lets-try-react-without-nodejs-3a7

    I'm not known about React, but I could run the example inside the link:

    1. Because Babel.js is used to compile React snippet, so we should also change script tag to:

     pastedimage1577346920181v1.png

    2. By doing this my web resource could run React code.

    (I opened it with openWebResource)

    var windowOptions = { height: 400, width: 400 }
    Xrm.Navigation.openWebResource("new_react_example",windowOptions);

    HTML:

    pastedimage1577347035221v2.png

    HTML code:

    
      
      
      
      React Local
      
      
      
    
    
    
      

    js in React style:

    pastedimage1577347067368v3.png

    js code:

    // Obtain the root 
    const rootElement = document.getElementById('root')
    // Create a ES6 class component    
    class ShoppingList extends React.Component {
        // Use the render function to return JSX component      
        render() {
            return (
                

    Module List for {this.props.name}

    • Sales
    • Customer Service
    • Marketing
    ); } } // Create a function to wrap up your component function App() { return (
    ) } // Use the ReactDOM.render to show your component on the browser ReactDOM.render( , rootElement )

    result:

    pastedimage1577347114688v4.png

    So please change the script tag attribute and refered js link to test again.

    Regards,

    Clofly

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Import Web Resource (html/react) with multiple scripts files (WITHOUT NODE.JS)

    Hello,

    I haven't done that myself but some of my colleagues use gulp for that purpose - www.davepaquette.com/.../how-to-use-gulp-in-visual-studio.aspx

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 172

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 75 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans