C# Class React.ReactComponent

Represents a React JavaScript component.
Inheritance: IReactComponent
Datei anzeigen Open project: reactjs/React.NET Class Usage Examples

Protected Properties

Property Type Description
_configuration IReactSiteConfiguration
_environment IReactEnvironment
_props object
_serializedProps string

Public Methods

Method Description
ReactComponent ( IReactEnvironment environment, IReactSiteConfiguration configuration, string componentName, string containerId ) : System

Initializes a new instance of the ReactComponent class.

RenderHtml ( bool renderContainerOnly = false, bool renderServerOnly = false ) : string

Renders the HTML for this component. This will execute the component server-side and return the rendered HTML.

RenderJavaScript ( ) : string

Renders the JavaScript required to initialise this component client-side. This will initialise the React component, which includes attach event handlers to the server-rendered HTML.

Protected Methods

Method Description
EnsureComponentExists ( ) : void

Ensures that this component exists in global scope

GetComponentInitialiser ( ) : string

Gets the JavaScript code to initialise the component

Private Methods

Method Description
EnsureComponentNameValid ( string componentName ) : void

Validates that the specified component name is valid

GenerateId ( ) : string

Generates a unique identifier for this component, if one was not passed in.

Method Details

EnsureComponentExists() protected method

Ensures that this component exists in global scope
protected EnsureComponentExists ( ) : void
return void

GetComponentInitialiser() protected method

Gets the JavaScript code to initialise the component
protected GetComponentInitialiser ( ) : string
return string

ReactComponent() public method

Initializes a new instance of the ReactComponent class.
public ReactComponent ( IReactEnvironment environment, IReactSiteConfiguration configuration, string componentName, string containerId ) : System
environment IReactEnvironment The environment.
configuration IReactSiteConfiguration Site-wide configuration.
componentName string Name of the component.
containerId string The ID of the container DIV for this component
return System

RenderHtml() public method

Renders the HTML for this component. This will execute the component server-side and return the rendered HTML.
public RenderHtml ( bool renderContainerOnly = false, bool renderServerOnly = false ) : string
renderContainerOnly bool Only renders component container. Used for client-side only rendering.
renderServerOnly bool Only renders the common HTML mark up and not any React specific data attributes. Used for server-side only rendering.
return string

RenderJavaScript() public method

Renders the JavaScript required to initialise this component client-side. This will initialise the React component, which includes attach event handlers to the server-rendered HTML.
public RenderJavaScript ( ) : string
return string

Property Details

_configuration protected_oe property

Global site configuration
protected IReactSiteConfiguration _configuration
return IReactSiteConfiguration

_environment protected_oe property

Environment this component has been created in
protected IReactEnvironment _environment
return IReactEnvironment

_props protected_oe property

Raw props for this component
protected object _props
return object

_serializedProps protected_oe property

JSON serialized props for this component
protected string _serializedProps
return string