-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/create-react-class@15.6.2/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>
David Schumann
  • 13,380
  • 9
  • 75
  • 96
DCR
  • 14,737
  • 12
  • 52
  • 115

1 Answers1

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>
Lorenzo Marcon
  • 8,029
  • 5
  • 38
  • 63
  • 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 – DCR Nov 09 '17 at 16:28
  • I'd definitely start with https://github.com/facebookincubator/create-react-app along with the official doc https://reactjs.org/tutorial/tutorial.html – Lorenzo Marcon Nov 09 '17 at 16:29