Skip to content
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

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

Open
swcarter007 opened this issue Apr 28, 2022 · 0 comments

Comments

@swcarter007
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant