Skip to content

Commit e30ec04

Browse files
Update tutorial documentation
Add a reference to installing a specific Javascript engine, which was only present in the getting started docs. Fixes #645
1 parent d3a1235 commit e30ec04

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

site/jekyll/tutorials/aspnet4.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ We need to install ReactJS.NET to the newly-created project. This is accomplishe
4545

4646
<img src="/img/tutorial/nuget.png" alt="Screenshot: Install NuGet Packages" width="650" />
4747

48+
You will also need to install a JS engine to use (either V8 or ChakraCore are recommended). See the [JSEngineSwitcher docs](https://github.com/Taritsyn/JavaScriptEngineSwitcher/wiki/Registration-of-JS-engines) for more information.
49+
50+
To use V8, add the following packages:
51+
52+
```
53+
JavaScriptEngineSwitcher.V8
54+
JavaScriptEngineSwitcher.V8.Native.win-x64
55+
```
56+
57+
`ReactConfig.cs` will be automatically generated for you. Update it to register a JS engine:
58+
59+
```csharp
60+
using JavaScriptEngineSwitcher.Core;
61+
using JavaScriptEngineSwitcher.V8;
62+
63+
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(React.Sample.Mvc4.ReactConfig), "Configure")]
64+
65+
namespace React.Sample.Mvc4
66+
{
67+
public static class ReactConfig
68+
{
69+
public static void Configure()
70+
{
71+
JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;
72+
JsEngineSwitcher.Current.EngineFactories.AddV8();
73+
}
74+
}
75+
}
76+
```
77+
4878
### Create basic controller and view
4979

5080
Since this tutorial focuses mainly on ReactJS.NET itself, we will not cover creation of an MVC controller in much detail. To learn more about ASP.NET MVC, refer to [its official website](https://www.asp.net/mvc).

site/jekyll/tutorials/aspnetcore.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ At the top of the file, add:
6666

6767
```csharp
6868
using Microsoft.AspNetCore.Http;
69+
using JavaScriptEngineSwitcher.Core;
70+
using JavaScriptEngineSwitcher.ChakraCore;
6971
using React.AspNet;
7072
```
7173

@@ -81,6 +83,10 @@ Add:
8183
```csharp
8284
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
8385
services.AddReact();
86+
87+
// Make sure a JS engine is registered, or you will get an error!
88+
services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName)
89+
.AddChakraCore();
8490
```
8591

8692
Directly **above**:

0 commit comments

Comments
 (0)