Reputation: 8137
I have the reactjs nuget packages and they're working as expected.
I want to transpile to js from the jsx syntax on the server side using a string I retrieved from the database, rather than from a .jsx file.
React
has a Babel
class in C# (using React Core in .net MVC Core app). However, it is not apparent how to use this manually. I imagine that React is simply getting the string value of the .jsx files and converting so this should be rather straightforward... though I could be wrong.
Upvotes: 2
Views: 2098
Reputation: 8065
You can use react.net to do that as follows.
string jsCode = ReactEnvironment.Current.Babel.Transform("<div/>");
This will return converted JS code as a string.
Upvotes: 2