-
Notifications
You must be signed in to change notification settings - Fork 920
Description
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!