You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: site/jekyll/_posts/2016-10-09-3.0.0-release.md
+1
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ I'm happy to announce the release of ReactJS.NET 3.0! The major change in this r
16
16
Other tweaks:
17
17
18
18
*[#323](https://github.com/reactjs/React.NET/issues/323) - Upgraded to React 15.3.2
19
+
*[#331](https://github.com/reactjs/React.NET/issues/331) - Added option to totally disable server-side rendering. This is useful when debugging your React components, as it's easier to debug client-side
19
20
*[#316](https://github.com/reactjs/React.NET/issues/316) - Added option to use production version of React, and enabled it by default. You can call `SetUseDebugReact(true)` in your ReactJS.NET config to use the debug version. The production version of React is much faster than the debug build, but it has less useful error messages if something does go wrong.
20
21
*[#299](https://github.com/reactjs/React.NET/issues/299) - Use file hash to check for file changes before transpiling. *Thanks to [Torben Rahbek Koch](https://github.com/TorbenRahbekKoch)*
21
22
*[#317](https://github.com/reactjs/React.NET/issues/317) - Switched to [Paul Knopf](https://github.com/pauldotknopf)'s branch of VroomJs (V8 for Linux / Mac OS) rather than maintaining our own fork
Copy file name to clipboardexpand all lines: site/jekyll/getting-started/aspnetcore.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ layout: docs
4
4
title: Getting Started on ASP.NET Core
5
5
---
6
6
7
-
Getting started with ReactJS.NET on ASP.NET Core requires a few more steps compared to previous versions of ASP.NET and MVC. A more fully featured tutorial will be released soon.
7
+
Getting started with ReactJS.NET on ASP.NET Core requires a few more steps compared to previous versions of ASP.NET and MVC. If you want a step-by-step guide on configuring a brand new site, see [the ReactJS.NET tutorial for ASP.NET Core](/getting-started/tutorial.html).
8
8
9
-
ReactJS.NET requires Visual Studio 2015 and ASP.NET Core RTM (final release). Additionally, ReactJS.NET does not support .NET Core at this point in time, so you will need to ensure your project is not referencing it. If you're creating a new website, use the "ASP.NET Core Web Application (.NET Framework)" project template. Otherwise, make sure your `project.json` references `net452` in its `frameworks` section, **not**`netcoreapp`.
9
+
ReactJS.NET requires Visual Studio 2015 and ASP.NET Core RTM (final release). It is recommended to use .NET Framework, but ReactJS.NET also works with .NET Core.
10
10
11
11
Install the `React.AspNet` package through NuGet. After the package is installed, ReactJS.NET needs to be initialised in your `Startup.cs` file (unfortunately this can not be done automatically like in previous versions of ASP.NET with WebActivator). At the top of the file, add:
12
12
@@ -66,4 +66,4 @@ Finally, add this to `Views\_ViewImports.cshtml` (or create it if it doesn't exi
66
66
@usingReact.AspNet
67
67
```
68
68
69
-
Once ReactJS.NET has been configured, you will be able to use [on-the-fly JSX to JavaScript compilation](http://reactjs.net/getting-started/usage.html) and [server-side rendering](http://reactjs.net/guides/server-side-rendering.html).
69
+
Once ReactJS.NET has been configured, you will be able to use [on-the-fly JSX to JavaScript compilation](/getting-started/usage.html) and [server-side rendering](/guides/server-side-rendering.html).
@@ -414,7 +418,7 @@ public ActionResult Comments()
414
418
}
415
419
```
416
420
417
-
The OutputCache attribute is used here to prevent browsers from caching the response. When designing a real world API, caching of API requests should be considered more carefully. For this tutorial it is easiest to simply disable caching.
421
+
The `OutputCache` attribute is used here to prevent browsers from caching the response. When designing a real world API, caching of API requests should be considered more carefully. For this tutorial it is easiest to simply disable caching.
418
422
419
423
Finally we add a corresponding route in `App_Start\RouteConfig.cs`:
420
424
@@ -461,6 +465,8 @@ ReactDOM.render(
461
465
);
462
466
```
463
467
468
+
Note that in a real app, you should generate the URL server-side (via `Url.Action` call) and pass it down, or use [RouteJs](http://dan.cx/projects/routejs) rather than hard-coding it. This tutorial hard-codes it for simplicity.
469
+
464
470
This component is different from the prior components because it will have to re-render itself. The component won't have any data until the request from the server comes back, at which point the component may need to render some new comments.
465
471
466
472
### Reactive state
@@ -566,6 +572,8 @@ To accept new comments, we need to first add a controller action to handle it. T
566
572
[HttpPost]
567
573
publicActionResultAddComment(CommentModelcomment)
568
574
{
575
+
// Create a fake ID for this comment
576
+
comment.Id=_comments.Count+1;
569
577
_comments.Add(comment);
570
578
returnContent("Success :)");
571
579
}
@@ -973,9 +981,9 @@ var CommentBox = React.createClass({
973
981
var newComments = comments.concat([comment]);
974
982
this.setState({data: newComments});
975
983
976
-
var data = new FormData();
977
-
data.append('Author', comment.Author);
978
-
data.append('Text', comment.Text);
984
+
var data = new FormData();
985
+
data.append('Author', comment.Author);
986
+
data.append('Text', comment.Text);
979
987
980
988
var xhr = new XMLHttpRequest();
981
989
xhr.open('post', this.props.submitUrl, true);
@@ -1002,6 +1010,16 @@ var CommentBox = React.createClass({
1002
1010
});
1003
1011
```
1004
1012
1013
+
We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable:
1014
+
```javascript{3}
1015
+
var Comment = React.createClass({
1016
+
rawMarkup: function () {
1017
+
var md = new (global.Remarkable || window.Remarkable)();
1018
+
var rawMarkup = md.render(this.props.children.toString());
1019
+
return { __html: rawMarkup };
1020
+
},
1021
+
```
1022
+
1005
1023
In the view, we will accept the list of comments as the model, and use `Html.React` to render the component. This will replace the `ReactDOM.render` call that currently exists in Tutorial.jsx. All the props from the current `ReactDOM.render` call should be moved here, and the `ReactDOM.render` call should be deleted.
1006
1024
1007
1025
```html{1,10-16,21}
@@ -1053,12 +1071,15 @@ namespace ReactDemo
1053
1071
public static void Configure()
1054
1072
{
1055
1073
ReactSiteConfiguration.Configuration
1074
+
.AddScript("~/js/remarkable.min.js")
1056
1075
.AddScript("~/Scripts/Tutorial.jsx");
1057
1076
}
1058
1077
}
1059
1078
}
1060
1079
```
1061
1080
1081
+
Note that we need a copy of Remarkable in order to load it for server-side rendering. In a production app you'd probably use Bower or npm for this, but for our tutorial you can just [download the file from CDNJS](https://cdnjs.cloudflare.com/ajax/libs/remarkable/1.7.1/remarkable.min.js) and save it into `~/js`.
1082
+
1062
1083
That's it! Now if you build and refresh your application, you should notice that the comments box is rendered immediately rather than having a slight delay. If you view the source of the page, you will see the initial comments directly in the HTML itself:
Copy file name to clipboardexpand all lines: site/jekyll/guides/server-side-rendering.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ to wait for all the JavaScript to load before seeing the web page.
9
9
10
10
To use server-side rendering in your application, follow the following steps:
11
11
12
-
1 - Modify `App_Start\ReactConfig.cs` to reference your components:
12
+
1 - Modify `App_Start\ReactConfig.cs`(for ASP.NET MVC 4 or 5) or `Startup.cs` (for ASP.NET Core) to reference your components:
13
13
14
14
```csharp
15
15
namespaceMyApp
@@ -72,12 +72,14 @@ code.
72
72
The server-rendered HTML will automatically be reused by React client-side,
73
73
meaning your initial render will be super fast.
74
74
75
+
If you encounter any errors with the JavaScript, you may want to temporarily disable server-side rendering in order to debug your components in your browser. You can do this by calling `DisableServerSideRendering()` in your ReactJS.NET config.
76
+
75
77
For a more in-depth example, take a look at the included sample application
76
78
(**React.Samples.Mvc4**).
77
79
78
80
5 - Server-side only rendering
79
81
80
-
If there is no need to have a React application client side and you just want to use the server side rendering but without the React specific data attributes call `Html.React` and pass serverOnly parameter as true.
82
+
If there is no need to have a React application client side and you just want to use the server side rendering but without the React specific data attributes, call `Html.React` and pass serverOnly parameter as true.
81
83
82
84
```csharp
83
85
@Html.React("HelloWorld", new
@@ -86,7 +88,7 @@ If there is no need to have a React application client side and you just want to
86
88
}, serverOnly: true)
87
89
```
88
90
89
-
And the Html mark up will look like the one following which is a lot cleaner. In this case there is no need to load the React script or call the `Html.ReactInitJavaScript()` method.
91
+
And the HTML will look like the one following which is a lot cleaner. In this case there is no need to load the React script or call the `Html.ReactInitJavaScript()` method.
0 commit comments