@@ -68,6 +68,7 @@ private static IReactEnvironment Environment
68
68
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
69
69
/// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to <c>false</c></param>
70
70
/// <param name="serverOnly">Skip rendering React specific data-attributes during server side rendering. Defaults to <c>false</c></param>
71
+ /// <param name="containerClass">HTML class(es) to set on the container tag</param>
71
72
/// <returns>The component's HTML</returns>
72
73
public static IHtmlString React < T > (
73
74
this IHtmlHelper htmlHelper ,
@@ -76,14 +77,19 @@ public static IHtmlString React<T>(
76
77
string htmlTag = null ,
77
78
string containerId = null ,
78
79
bool clientOnly = false ,
79
- bool serverOnly = false
80
+ bool serverOnly = false ,
81
+ string containerClass = null
80
82
)
81
83
{
82
84
var reactComponent = Environment . CreateComponent ( componentName , props , containerId ) ;
83
85
if ( ! string . IsNullOrEmpty ( htmlTag ) )
84
86
{
85
87
reactComponent . ContainerTag = htmlTag ;
86
88
}
89
+ if ( ! string . IsNullOrEmpty ( containerClass ) )
90
+ {
91
+ reactComponent . ContainerClass = containerClass ;
92
+ }
87
93
var result = reactComponent . RenderHtml ( clientOnly , serverOnly ) ;
88
94
return new HtmlString ( result ) ;
89
95
}
@@ -100,21 +106,27 @@ public static IHtmlString React<T>(
100
106
/// <param name="htmlTag">HTML tag to wrap the component in. Defaults to <div></param>
101
107
/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
102
108
/// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to <c>false</c></param>
109
+ /// <param name="containerClass">HTML class(es) to set on the container tag</param>
103
110
/// <returns>The component's HTML</returns>
104
111
public static IHtmlString ReactWithInit < T > (
105
112
this IHtmlHelper htmlHelper ,
106
113
string componentName ,
107
114
T props ,
108
115
string htmlTag = null ,
109
116
string containerId = null ,
110
- bool clientOnly = false
117
+ bool clientOnly = false ,
118
+ string containerClass = null
111
119
)
112
120
{
113
121
var reactComponent = Environment . CreateComponent ( componentName , props , containerId ) ;
114
122
if ( ! string . IsNullOrEmpty ( htmlTag ) )
115
123
{
116
124
reactComponent . ContainerTag = htmlTag ;
117
125
}
126
+ if ( ! string . IsNullOrEmpty ( containerClass ) )
127
+ {
128
+ reactComponent . ContainerClass = containerClass ;
129
+ }
118
130
var html = reactComponent . RenderHtml ( clientOnly ) ;
119
131
120
132
#if LEGACYASPNET
0 commit comments