-
Notifications
You must be signed in to change notification settings - Fork 926
Please do not pollute my DOM #45
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
Thanks for reporting this! I had a TODO comment in the code to allow specifying the HTML tag to use, so you could do something like |
Yeap, a span solves my use case. Maybe it could be used as default since it is less obtrusive than div. Ideally we would really want the wrapper to not be there at all, since its not expected. I have done some research, correct me if I am wrong. React components already have a wrapper div since siblings are not allowed. div class="comments-box" data-reactid=".t66cpxj1cn" data-react-checksum="1948633873">...</div Would it be possible to use following when initializing? document.querySelector('[data-reactid=".t66cpxj1cn"]'); |
I added the ability to select the tag you want to use in 303ab72. This is included in I can't make You can't manually touch any of the DOM nodes with I'm going to close this task since there's now a fix available. Thanks for reporting it! |
Thanks for the quick fix! |
Hi Daniel - I have the same need as was originally listed which was to be able to define the value of the ID instead of it being auto populated as react#. Should I open a new ticket? Or would you like me to make the changes and submit them? Let me know, thanks! |
|
@mocanSergiu666 - |
To render just the component (with an optional reactId), the following extension method should do the trick:
To use it in your cshtml, just write the following:
Please note that this extension method reaches quite far into ReactJs.net. It might get you into trouble down the road. |
Really like the server-side rendering but got one problem with it. Is it possible to not include the extra "react1" container div since it messes with the CSS. Would be great if there was an additional optional parameter on the helper like this:
@Html.React("HelloWorld", new {name = "Daniel"}, "my-own-container")
If the optional parameter is specified no "react1" div is rendered and the optional is used when doing:
document.getElementById("my-own-container")
The text was updated successfully, but these errors were encountered: