4

I am playing around with https://reactjs.net/ , and want to setup an application inside my existing ASP.NET MVC application.

I have made a couple of simple React applications using the "default installation template" inside Visual Studio, but not based on ReactJS.net and where the content is only a subpage.

However, if I take the tutorial template used as examples:

var CommentBox = React.createClass({
    render: function () {
        return (
            <div className="commentBox">
                Hello, world! I am a CommentBox.
      </div>
        );
    }
});
ReactDOM.render(
    <CommentBox />,
    document.getElementById('content')
);

There are no importing React like: import * as React from 'react'; , which I am used to.

So my question is: why not? And when are you supposed to import React?

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
  • It's probably abstracted out in the website. You absolutely have to import `React` in any file you want to use it in your web app – Andrew Apr 01 '18 at 18:13

1 Answers1

0

Because import React from 'react'; is required when you are trying to import npm packages. Reactjs.Net doesn't use npm dependency and you're required to put the CDNs in your view using <script src="">. Basically, you're importing React automatically when you use the CDNs

Riadhoq
  • 399
  • 5
  • 9