useDevicesProps(selector: (devicesProps: { [key: string]: DpState }) => DpValue;, equalityFn?: (prev: DpValue, next: DpValue) => boolean;)
Requires:
@ray-js/panel-sdk≥1.16.0
Additional notesRead the full notes
Before use, mount SdmDevicesProvider and configure the associated device mapping.
Performance optimization (best practices):
1. Strongly recommend always scoping the selector to the exact feature point, e.g., useDevicesProps(props => props.main?.switch_led), to avoid full subscriptions that cause unnecessary rerenders when unrelated devices or feature points change.
2. If the selector must return an object containing multiple fields, the default shallow comparison (shallow equal) ensures rerender will not be triggered as long as the extracted values do not change. If needed, pass a custom equalityFn.
Performance optimization (best practices):
1. Strongly recommend always scoping the selector to the exact feature point, e.g., useDevicesProps(props => props.main?.switch_led), to avoid full subscriptions that cause unnecessary rerenders when unrelated devices or feature points change.
2. If the selector must return an object containing multiple fields, the default shallow comparison (shallow equal) ensures rerender will not be triggered as long as the extracted values do not change. If needed, pass a custom equalityFn.
Description
Get the DP state set of associated devices.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
selector | (devicesProps: { [key: string]: DpState }) => DpValue; | Yes | Selector function. The input is the props aggregation object for all associated devices. Keys are device identifiers, and values are the device’s DP key–value pairs |
equalityFn | (prev: DpValue, next: DpValue) => boolean; | No | Custom comparison function; if it returns true, re-render is not triggered; default is shallow equal |
Return Value
Type: DpValue
DP values selected by the selector; type is inferred from the selector’s return value
Referenced Types
type
DpStateDatapoint status object, where the key is the datapoint code and the value is the datapoint value.type
DpValueDatapoint value type, which can be boolean, number, or string.