React and .NET Core

0

I am trying to use React in my existing .net core MVC application. I have done everything specified in here: https://medium.com/@mirela95/asp-net-core-2-0-mvc-with-reactjs-net-basic-setup-and-example-template-4811b10b114a

It complained that ReactJSengine is not registered. Then I installed JavaScriptEngineSwitcher.ChakraCore and JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64 on my machine. It now gives the following error:

DllNotFoundException: Unable to load DLL 'ChakraCore' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) JavaScriptEngineSwitcher.ChakraCore.JsRt.NativeMethods.JsCreateRuntime(JsRuntimeAttributes attributes, JsThreadServiceCallback threadService, out JsRuntime runtime)

JsEngineLoadException: Failed to create an instance of the ChakraCoreJsEngine. Most likely it happened because the 'ChakraCore.dll' assembly or one of its dependencies was not found. Try to install the JavaScriptEngineSwitcher.ChakraCore.Native.win-x64 package via NuGet. JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine..ctor(ChakraCoreSettings settings)

TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) in TinyIoC.cs, line 4060

TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) in TinyIoC.cs, line 4041

ReactNotInitialisedException: ReactJS.NET has not been initialised correctly. Please ensure you have called services.AddReact() and app.UseReact() in your Startup.cs file. React.ReactEnvironment.get_GetCurrentOrThrow() in ReactEnvironment.cs, line 105

My Startup.cs has the following entries:

 app.UseReact(config =>
       {
             config
                .SetLoadBabel(true)
                .AddScriptWithoutTransform("~/ReactContent/bundle.js")
                .AddScript("~/ReactContent/Components/ExampleComponent.jsx");
       });

 services.AddJsEngineSwitcher(options => 
    options.DefaultEngineName =ChakraCoreJsEngine.EngineName).AddChakraCore();
 services.AddReact();

I am not sure how to resolve this. Please help me with this.

Also, I need some links to good tutorials for using React in .net core MVC application. Is it good to use ReactJS.NET package or should I just use React.js? Any advice is greatly appreciated.

Thanks Deepthi

c#
reactjs
reactjs.net
asked on Stack Overflow Nov 28, 2019 by Deepthi • edited Nov 28, 2019 by Valkyrie

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0