-
Notifications
You must be signed in to change notification settings - Fork 5
sp webpart base.basewebpart.onafterdeserialize
Home > @microsoft/sp-webpart-base > BaseWebPart > onAfterDeserialize
This API is called after the web part is deserialized to an object, right before the property bag is populated. virtual
Signature:
protected onAfterDeserialize(deserializedObject: any, dataVersion: Version): TProperties;
Parameter | Type | Description |
---|---|---|
deserializedObject | any | The object deserialized from the stored data. Note that the schema of this object is not necessarily consistent with the current property bag, because the serialization could have been done by an older version of the web part |
dataVersion | Version | The data version of the stored data being deserialized. You can use this value to determine if the data was serialized by an older web part. Web parts can define their data version by overriding the dataVersion property. |
Returns:
TProperties
The property bag of the web part
The default implementation is a no-op. A web part developer can override this API if the deserialized object does not fully reflect the initial state of the property bag. This gives the web part developer a chance to populate the property bag right after the data is deserialized to an object.
An important scenario to use deserialize is upgrading. An upgraded web part may load the data that was serialized by an older version of the web part that supported a different schema of the property bag, resulting the deserialized object to be incosistent with the current schema of the property bag. The developer can use onAfterDeserialize
to check the dataVersion and fix the property bag.