-
Notifications
You must be signed in to change notification settings - Fork 926
Document WebForms integration #967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After reading the documentation on webpack section a bit further. Looks like I can just use webpack itself and that will mean I can definitely run the project by itself (question 4 answered) and then also run the bundles inside my ASP.NET application. But in that case I could just add the React stuff into the Project and just have a task that on startup builds the webpack build and runs the app? Almost eliminating the need for React.NET entirely. |
Correct, webpack is a suitable alternative. Some people don’t want to go
through the trouble of that for small projects.
You can still leverage server side rendering if using webpack, check out
the samples if you want to see how that’s done.
Cheers
…On Tue, Nov 5, 2019 at 21:44, pmonty ***@***.***> wrote:
After reading the documentation on webpack section a bit further. Looks
like I can just use webpack itself and that will mean I can definitely run
the project by itself (question 4 answered) and then also run the bundles
inside my ASP.NET application.
But in that case I could just add the React stuff into the Project and
just have a task that on startup builds the webpack build and runs the app?
Almost eliminating the need for React.NET entirely.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#967?email_source=notifications&email_token=AAHGCFTFOEGQIQNSICO3M63QSJKVPA5CNFSM4JJPQ752YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDFLBNI#issuecomment-550154421>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHGCFRXJLHJ43EOQNG2IJLQSJKVPANCNFSM4JJPQ75Q>
.
|
Yeh will give the webpack path a go. Only concern is... can I have the webpack config, package.json and tsconfig files in the EDIT: |
Ok so after some following along with the sample I have the following VB.NET setup. ReactSiteConfiguration.
Configuration.
SetReuseJavaScriptEngines(True).
AddScriptWithoutTransform("~/Clientapp/dist/routes.bundle.js")
JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName
JsEngineSwitcher.Current.EngineFactories.AddV8() test.aspx <asp:Literal ID="route1" runat="server"></asp:Literal>
<script src="~/Clientapp/dist/routes.bundle.js"></script> test.aspx.vb Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim env = ReactEnvironment.Current
env.GetInitJavaScript()
Dim objectModel = New With {Key .route = "route1"}
Dim reactComponent = env.CreateComponent("Routes.Route1", objectModel)
route1.Text = reactComponent.RenderHtml()
End Sub index.js import { Route1 } from './Route1'
import { Route2 } from './Route2'
global.Routes = { Route1, Route2 } Route1/index.tsx import * as React from 'react'
export class Route2 extends React.Component<any> {
render = () => {
return (
<div>Hello world from {this.props.route}</div>
);
}
} But when I run it I get https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=t UPDATE: |
Interesting! I think for the sake of keeping the docs focused on using a single language, we should stick with C#. However adding a brief section on calling from WebForms would be very useful! |
So got back on to this project after a hiatus and one situation which is strange is occurring when I create a simple component and import it into the parent. Component.tsx
index.tsx
I get Update: Update2: |
Hey @pmonty I think at this point this github issue will do a good enough job getting folks started with using WebForms :) given that MS is actively pushing people away from it (no new updates, no .NET 5 support) I hope folks will reach for an incremental MVC port before they reach for this library. |
So wondering if this is possible. Since I have finally managed to get React.NET working with my ASP.NET Web Forms project (VB.NET). I was wondering if it is possible to have some kind of way to flag when to use it.
Idea I have in my head is to somehow based on the
Solution Configuration
setting I can do the following.If it is set to
Release
then it will build with Webpack. If set toDebug
then it will use the setup I have working in #963 to run.I am thinking of something this where IsDebug is a directive check on
DEBUG
My questions from that setup though are:
IsDebug()
in eachaspx.vb
page code now so it doesn't error?<script src="../bundles/bundle1.js" />
in the respective pages will work for Release I guess and 404 in Debug? which I am fine with if its only debug mode.The text was updated successfully, but these errors were encountered: