React.NET icon indicating copy to clipboard operation
React.NET copied to clipboard

Add ability to skip adding component to the list of components for @Html.React or @Html.ReactWithInit

Open swcarter007 opened this issue 3 years ago • 0 comments

Thanks for filing a bug! To save time, if you're having trouble using the library, please check off the items you have tried. If you are just asking a question, skip right to the bottom.

I'm using these library versions:

  • ReactJS.NET: 5.2.12

Runtime environment:

  • .NET Framework or .NET Core Version:

Steps to reproduce

  1. Load component with @Html.ReactWithInit()
  2. Add @Html.ReactInitJavascript() lower on the page
  3. Component ReactDOM.hydrate method is added within the component within the DomContentLoaded right below the @Html.ReactWithInit() function, and again without the DCL next to to the @Html.ReactInitJavascript() declaration.

The issue is that the code is duplicated onto the page adding unnecessary page weight.

Expected change: Update @Html.React and @Html.ReactWithInit function to accept the skipLazyInit property that is exposed on the CreateComponent() function to allow adding a component without readding it later on.

Use cases: The simple use case is to avoid duplicate code, but the secondary use case would be to be able to hydrate a component earlier on the page than trying to hydrate the rest of the components lower on with the @Html.ReactInitJavascript() code.

swcarter007 avatar Apr 28 '22 18:04 swcarter007