Reputation: 315
In C#, I get as an input a JSX file and want to translate it to JS. I want to use the babel library, and used this guide:https://babeljs.io/docs/setup/#installation
However, I am getting an exception of type:
An unhandled exception of type 'React.TinyIoC.TinyIoCResolutionException' occurred in React.Core.dll
Additional information: Unable to resolve type: React.IReactEnvironment
for this line: ReactEnvironment.Current
I have tried to create a new ASP.NET project, and no exception was thrown and everything worked just fine.
My question is: How can I still use babel in non web project?
Upvotes: 1
Views: 874
Reputation: 476
You need to run an extra initialization step for non Web applications. This initialization step is automatically done in Web applications.
If its a console application then use this function,
private static void Initialize()
{
Initializer.Initialize(registration => registration.AsSingleton());
var container = React.AssemblyRegistration.Container;
// Register some components that are normally provided by the integration library
// (eg. React.AspNet or React.Web.Mvc6)
container.Register<ICache, NullCache>();
container.Register<IFileSystem, SimpleFileSystem>();
}
And call it in the main method.
Take a look at the github console sample app for React.Net
Upvotes: 2