reactjs / React.NET

.NET library for JSX compilation and server-side rendering of React components
https://reactjs.net/
MIT License
2.29k stars 937 forks source link

[Help wanted] Server side render get ReactInvalidComponentException: Could not find a component named.Did you forget to add it to App_Start\ReactConfig.cs? #510

Closed ngohungphuc closed 6 years ago

ngohungphuc commented 6 years ago

I have a question that I have already add config.AddScript("~/wwwroot/dist/login.js"); in Starup

And In my view I add @Html.ReactInitJavaScript() but seem like the web doesnt boost up faster than I just add only script tag in the view.

Is my config right ? If not am I missing something to make server side render work as expected

dustinsoftware commented 6 years ago

Hi tony,

Are you calling HTML.React() where you want your component to render? ReactWithInit is used only at the very bottom of the page to initialize all of the rendered components.

On Mon, Feb 19, 2018 at 06:54, Tony Hudson notifications@github.com wrote:

I have a question that I have already add config.AddScript("~/wwwroot/dist/login.js"); in Starup https://github.com/Awesome-CMS-Core/Awesome-CMS-Core/blob/c2aa39486cd8f1452087661f31f0b4a817f3a69d/src/AwesomeCMSCore/AwesomeCMSCore/Extension/ApplicationBuilderExtensions.cs#L109

And In my view https://github.com/Awesome-CMS-Core/Awesome-CMS-Core/blob/c2aa39486cd8f1452087661f31f0b4a817f3a69d/src/AwesomeCMSCore/Modules/AwesomeCMSCore.Modules.Admin/Views/Account/Login.cshtml I add @Html.ReactInitJavaScript() but seem like the web doesnt boost up faster than I just add only script tag in the view.

Is my config right ? If not am I missing something to make server side render work as expected

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reactjs/React.NET/issues/510, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5hFqWOU422JtgY0UhA4Q0TAKxWiIIXks5tWYs0gaJpZM4SKrDr .

ngohungphuc commented 6 years ago

@dustinsoftware I just want to render a login form for user to login. That's all

I get the following error though I'm using ASP.Net Core 2.0 ReactInvalidComponentException: Could not find a component named 'LoginForm'. Did you forget to add it to App_Start\ReactConfig.cs?

My view

<div id="loginForm">
</div>

@section Scripts {
    @Html.React("LoginForm", new { })
    <script src="@Url.Content("~/dist/login.js")"></script>
    @Html.ReactInitJavaScript()
}
ngohungphuc commented 6 years ago

The problem I get is webpack mangle options so the class name React.Net cant find it. Still not find a way to fix it

ngohungphuc commented 6 years ago

@dustinsoftware any suggest