ReactControl.init
Used to initialize the component instance. Components can kick off remote server calls and other initialization actions. Dataset values cannot be initialized here, use the updateView method to achieve that.
trackContainerResize should be called once preferably in the component init
method to notify that the component needs the layout information . This indicates the framework to populate allocatedHeight
and allocatedWidth
methods.
Note
trackContainerResize
should be called first before the allocatedHeight
and allocatedWidth
methods.
Available for
Model-driven and canvas apps
Syntax
init(context,notifyOutputChanged,state)
Parameters
Parameter Name | Type | Required | Description |
---|---|---|---|
context | Context | yes | The Input Properties containing the parameters, component metadata and interface functions. |
notifyOutputChanged | function |
no | The method to notify the framework that it has new outputs |
state | Dictionary |
no | The component state that is saved from setControlState in the last session |
Note
The ReactControl.init method doesn't have a container
parameter with a HTMLDivElement
like the StandardControl.init method does. There is no container parameter because React controls do not render the DOM directly. Instead, the ReactControl.updateView method returns an ReactElement containing a description of the virtual control DOM.
Example
public init(
context: ComponentFramework.Context<IInputs>,
notifyOutputChanged: () => void,
state: ComponentFramework.Dictionary
): void {
this.notifyOutputChanged = notifyOutputChanged;
this.context.mode.trackContainerResize(true);
}
Related articles
React controls & platform libraries
ReactControl
Power Apps component framework API reference
Power Apps component framework overview