-
Notifications
You must be signed in to change notification settings - Fork 926
Allow control of the container ID #50
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, I'll add it this weekend. Sent from my phone.
|
Wow great, thanks! |
Thanks again - especially for the quick turn around! |
Hi - I need to be able to control the value of the ID that is currently being generated as "react#" - I thought you may have fixed this as part of #45 but instead that change allows the user to define the element type. Any chance you could include the ability to change the id? I think others would be happy to have this ability as well.
Your code is setup well to allow for this change easily, something like so is all I need:
Addition on the Extension:
public static IHtmlString React(
this HtmlHelper htmlHelper,
string componentName,
T props,
string htmlTag = null,
string htmlId = null
)
{
var reactComponent = Environment.CreateComponent(componentName, htmlId, props);
if (!string.IsNullOrEmpty(htmlTag))
{
reactComponent.ContainerTag = htmlTag;
}
var result = reactComponent.RenderHtml();
return new HtmlString(result);
}
Addition on ReactEnvironment:
public virtual IReactComponent CreateComponent(string componentName, string componentDomId, T props)
{
EnsureUserScriptsLoaded();
if (string.IsNullOrEmpty(componentDomId))
{
_maxContainerId++;
componentDomId = string.Format(CONTAINER_ELEMENT_NAME, _maxContainerId);
}
var component = new ReactComponent(this, _config, componentName, componentDomId)
{
Props = props
};
_components.Add(component);
return component;
}
Thanks!
The text was updated successfully, but these errors were encountered: