Skip to content

Engines are not returned to pool "per request" but rather "per Html.React method invocation" #487

@ryedin

Description

@ryedin

see: https://github.com/reactjs/React.NET/blob/master/src/React.AspNet/HtmlHelperExtensions.cs#L84

I'm wondering why the engine is being returned to the pool after each call to Html.React, when in all of the comments/docs you indicate that it should be "per request" (and I believe a true "per request" model would be much better overall performance).

Performance concerns aside, the way this is working right now also prevents using things like reactive mobx stores on the server across calls to Html.React within a given request context. We want to be able to disconnect components from the data that drives them and use dependency injection (on the js side) to connect them to the data. This prevents us from having to explicitly push ALL props in at the top level (the so-called page-level component). This works fine for the client-side rendering, as expected, because there is only a single js execution context. We had assumed that there would also be a single js execution context on the server (per request), because that would make a lot of sense. However, we soon realized that our injected data (injected via subsequent calls to Html.React in various partials) is never made available, and is thus not actually being utilized for SSR.

Are there other reasons that I am not able to see that are preventing making the engine be truly a singleton across the entire request, rather than simply per call to Html.React?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions