Skip to content

@tripo3d/lens / react / useTraceProps

Function: useTraceProps() ​

ts
function useTraceProps(binding): Record<string, string>;

Defined in: src/react/use-trace-props.ts:19

声明式主原语:把 binding 映射成 data-trace* 属性对象,spread 到任意元素。

tsx
<button {...useTraceProps({ key: 'buy', params: { sku } })}>Buy</button>

重渲染即重算(params 变化自动反映);采集靠 core 的 DeclarativeCollector,在触发时刻读属性。 旧属性随新 props 对象自然丢弃(React diff 移除),无需 Vue 指令那套手动 removeAttribute。 渲染期保持纯计算,序列化错误延迟到提交后上报——StrictMode 双调用与并发渲染中被丢弃的 render 不产生副作用。

Parameters ​

ParameterType
bindingTraceBinding

Returns ​

Record<string, string>

基于 MIT 协议发布(内部使用)