ReactJS.NET MVC tutorial doesn't work?

后端 未结 4 1866
梦毁少年i
梦毁少年i 2021-01-12 09:40

I\'m trying to setup a new project in Visual Studio that is going to be MVC 5 with a single page app written in ReactJS. So I followed the guide on the ReactJS website.

4条回答
  •  时光说笑
    2021-01-12 10:15

    I figured it out - the tutorial is missing two things:

    1. The script inclusion should be done thus, with a type declaration:

    2. The JSX transformer needs to be included:

    So the full HTML output by the Razor view should look like this:

    
    
      
        Hello React
      
      
        

    Looks like they need to update their tutorial.

    Update:

    Commenter @DanielLoNigro added this helpful tip:

    Actually if you're using ReactJS.NET, you don't need to use the client-side JSXTransformer. Just ensure that the JSX handler is configured in your Web.config file (there should be a handler for .jsx).

提交回复
热议问题