-
Notifications
You must be signed in to change notification settings - Fork 5
sp webpart base.baseclientsidewebpart
Home > @microsoft/sp-webpart-base > BaseClientSideWebPart
This abstract class implements the the base functionality for a client-side web part. Every client-side web part needs to inherit from this class.
Signature:
export default abstract class BaseClientSideWebPart<TProperties> extends BaseWebPart<TProperties>
Extends: BaseWebPart<TProperties>
Along with the base functionality, this class provides some APIs that can be used by the web part. These APIs fall in two catagories.
The first category of APIs provide data and functionality. Example, the web part context (i.e. this.context). This API should be used to access contextual data relevant to this web part instance.
The second category of APIs provide a base implementation for the web part lifecycle and can be overridden for an updated implementation. The render() API is the only API that is mandatory to be implemented/overridden by a web part. All other life cycle APIs have a base implementation and can be overridden based on the needs of the web part. Please refer to the documentation of the individual APIs to make the right decision.
Constructor | Modifiers | Description |
---|---|---|
(constructor)() | Constructor for the BaseClientSideWebPart class. |
Property | Modifiers | Type | Description |
---|---|---|---|
canOpenPopupOnRender | boolean | This property indicates whether a web part can open a popup on initial render. | |
context | WebPartContext | Use the context object to access common services and state associated with the component. | |
domElement | HTMLElement | This property is a pointer to the root DOM element of the web part. This is a DIV element and contains the whole DOM subtree of the web part. | |
isRenderAsync | boolean | Indicates whether the web part is rendering in Async mode. | |
renderedFromPersistedData | boolean | This property indicates whether the web part was rendered from the persisted data (serialized state from the last time that the web part was saved) or not. | |
renderedOnce | boolean | This property indicates whether the web part has been rendered once or not. After the first time rendering, the value of this property is always true until a full re-render of the web part happens. | |
width | number | This propery returns the width of the container for the web part. |
Method | Modifiers | Description |
---|---|---|
clearError() | This API should be used to clear the error message from the web part display area. | |
onAfterResize(newWidth) | This API is invoked when the web part container dom element width is changed, e.g. when the browser browser window is resized and when the property pane is toggled open/closed. | |
onDisplayModeChanged(oldDisplayMode) | This event method is called when the display mode of a web part is changed. | |
onDispose() | This API should be used to refresh the contents of the PropertyPane. | |
render() | This API is called to render the web part. There is no base implementation of this API and the web part is required to override this API. | |
renderCompleted(error) | This API should be called by web parts that perform Async rendering. Those web part are required to override the isRenderAsync API and return true. One such example is web parts that render content in an IFrame. The web part initiates the IFrame rendering in the render() API but the actual rendering is complete only after the iframe loading completes. |
|
renderError(error) | This API should be used to render an error message in the web part display area. Also logs the error message using the trace logger. |