-1

I'm just using script tags to bring in the libraries. The examples cited are using require. Is there a way to avoid that? The other libraries seem to load fine.

I know this is depreciated but still wondering how to get the following example working:

<!DOCTYPE html>
<html>
<head>
    <script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script crossorigin src="https://cdn.jsdelivr.net/npm/[email protected]/create-react-class.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <title>React Example</title>
</head>
<body>
    <div id='container'></div>
    <script type='text/jsx'>
        var HelloComponent2 = React.createClass({
            render: function() {
                return (
                    <h1>Hello, classical</h1>
                );
            }
        });
        ReactDOM.render(
            <HelloComponent2 name='Blobby0' />,
            document.getElementById('container')
        );
    </script>
</body>
</html>
0

1 Answer 1

2

As you said, it's deprecated. Use an older version of React to make that example work:

<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/15.6.1/react-dom.js"></script>
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, but I would like to learn how to add the new library. Can you point me to a reference or resource? Seems like I need to use NPM and somehow modify the code but not really sure what all the steps are
I'd definitely start with github.com/facebookincubator/create-react-app along with the official doc reactjs.org/tutorial/tutorial.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.