Represents a React JavaScript component.
Inheritance: IReactComponent
Ejemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the specified React JavaScript component.
        /// </summary>
        /// <typeparam name="T">Type of the props</typeparam>
        /// <param name="componentName">Name of the component</param>
        /// <param name="props">Props to use</param>
        /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
        /// <param name="clientOnly">True if server-side rendering will be bypassed. Defaults to false.</param>
        /// <returns>The component</returns>
        public virtual IReactComponent CreateComponent <T>(string componentName, T props, string containerId = null, bool clientOnly = false)
        {
            if (!clientOnly)
            {
                EnsureUserScriptsLoaded();
            }

            var component = new ReactComponent(this, _config, componentName, containerId)
            {
                Props = props
            };

            _components.Add(component);
            return(component);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Creates an instance of the specified React JavaScript component.
		/// </summary>
		/// <typeparam name="T">Type of the props</typeparam>
		/// <param name="componentName">Name of the component</param>
		/// <param name="props">Props to use</param>
		/// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
		/// <param name="clientOnly">True if server-side rendering will be bypassed. Defaults to false.</param>
		/// <param name="serverOnly">True if this component only should be rendered server-side. Defaults to false.</param>
		/// <returns>The component</returns>
		public virtual IReactComponent CreateComponent<T>(string componentName, T props, string containerId = null, bool clientOnly = false, bool serverOnly = false)
		{
			if (!clientOnly)
			{
				EnsureUserScriptsLoaded();
			}

			var component = new ReactComponent(this, _config, _reactIdGenerator, componentName, containerId)
			{
				ClientOnly = clientOnly,
				Props = props,
				ServerOnly = serverOnly
			};
			_components.Add(component);
			return component;
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an instance of the specified React JavaScript component.
        /// </summary>
        /// <typeparam name="T">Type of the props</typeparam>
        /// <param name="componentName">Name of the component</param>
        /// <param name="props">Props to use</param>
        /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
        /// <returns>The component</returns>
        public virtual IReactComponent CreateComponent <T>(string componentName, T props, string containerId = null)
        {
            EnsureUserScriptsLoaded();
            if (string.IsNullOrEmpty(containerId))
            {
                _maxContainerId++;
                containerId = string.Format(CONTAINER_ELEMENT_NAME, _maxContainerId);
            }

            var component = new ReactComponent(this, _config, componentName, containerId)
            {
                Props = props
            };

            _components.Add(component);
            return(component);
        }