mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Add react tag helper. Clean up code and make it more consistent.
This commit is contained in:
@@ -1,24 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.NodeServices;
|
||||
using Microsoft.AspNet.NodeServices.React;
|
||||
|
||||
namespace ReactExample.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private INodeServices nodeServices;
|
||||
|
||||
public HomeController(INodeServices nodeServices) {
|
||||
this.nodeServices = nodeServices;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index(int pageIndex)
|
||||
public IActionResult Index(int pageIndex)
|
||||
{
|
||||
ViewData["ReactOutput"] = await ReactRenderer.RenderToString(this.nodeServices,
|
||||
moduleName: "ReactApp/components/ReactApp.jsx",
|
||||
baseUrl: Request.Path
|
||||
);
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@ namespace ReactExample
|
||||
{
|
||||
// Add MVC services to the services container.
|
||||
services.AddMvc();
|
||||
|
||||
// Enable Node Services
|
||||
services.AddNodeServices();
|
||||
}
|
||||
|
||||
// Configure is called after ConfigureServices is called.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="react-app">@Html.Raw(ViewData["ReactOutput"])</div>
|
||||
<div id="react-app" asp-react-prerender-module="ReactApp/components/ReactApp.jsx"></div>
|
||||
|
||||
@section scripts {
|
||||
<script src="bundle.js"></script>
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
@using ReactExample
|
||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
||||
@addTagHelper "*, Microsoft.AspNet.NodeServices.React"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"Microsoft.Framework.Logging": "1.0.0-beta8",
|
||||
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
|
||||
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
|
||||
"Microsoft.AspNet.NodeServices.React": "1.0.0-alpha3"
|
||||
"Microsoft.AspNet.NodeServices.React": "1.0.0-alpha4"
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Server.Kestrel"
|
||||
|
||||
Reference in New Issue
Block a user