Device SupportGroup Support
useStructuredProps(selector?: (structuredProps: object) => any, equalityFn?: (prev: any, next: any) => boolean)
Requires:
@ray-js/panel-sdk≥1.10.0
Additional notesRead the full notes
Implemented on top of the sdm instance and the dp-kit interceptor. Must be used inside SdmProvider.
Before using, make sure SdmProvider has been mounted. For integration, see Smart Device Model - Usage. For new projects, you can develop directly based on the public-sdm example.
Before using, also make sure the dp-kit interceptor is configured; see Interceptors - Usage.
For simplicity and stability, useStructuredProps only returns DPs that have protocol rules configured; it does not return basic data-type DPs.
Typical scenario: composite string fields such as colour_data are automatically parsed by dp-kit according to protocols into structured objects like
{ hue, saturation, value }.
Before using, make sure SdmProvider has been mounted. For integration, see Smart Device Model - Usage. For new projects, you can develop directly based on the public-sdm example.
Before using, also make sure the dp-kit interceptor is configured; see Interceptors - Usage.
For simplicity and stability, useStructuredProps only returns DPs that have protocol rules configured; it does not return basic data-type DPs.
Typical scenario: composite string fields such as colour_data are automatically parsed by dp-kit according to protocols into structured objects like
{ hue, saturation, value }.
Description
Get the structured DP state parsed by dp-kit protocols; when the state changes, it triggers component re-rendering
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
selector | (structuredProps: object) => any | No | Selector function. Input: the structured state object (the value type of each key is determined by the return value of the corresponding Transformer.parser() in protocols). Return the part to subscribe to; if omitted, returns the entire structured DP state. Note: basic data-type DPs are not returned. |
equalityFn | (prev: any, next: any) => boolean | No | Custom comparator. Inputs are the previous and next selector return values; return true to skip re-rendering. Defaults to shallow equal |
Return Value
Type: any
The selector’s return value, with type determined by the selector; if no selector is provided, returns the full structured state object (the value type of each key equals the return type of the corresponding Transformer.parser()).