From UE_ReactUMG
ReactUMG TArray/数组属性处理指南。在传递数组给 UE 组件、使用 GridPanel 的 ColumnFill/RowFill、或遇到"不能用 JS 数组"问题时激活。必须用 UE.NewArray() 创建原生数组,包含 BuiltinFloat/String/Int 等类型常量。
How this skill is triggered — by the user, by Claude, or both
Slash command
/UE_ReactUMG:handling-tarraysThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**TArray 属性必须使用 `UE.NewArray()`,不能直接使用 JS 数组!**
TArray 属性必须使用 UE.NewArray(),不能直接使用 JS 数组!
// ❌ 错误:直接使用 JS 数组
<GridPanel ColumnFill={[1, 1, 1]} /> // Type Error!
// ✅ 正确:使用 UE.NewArray()
const columnFill = UE.NewArray(UE.BuiltinFloat);
columnFill.Add(1, 1, 1);
<GridPanel ColumnFill={columnFill} />
| 常量 | TypeScript 类型 | 用途 |
|---|---|---|
UE.BuiltinFloat | number | 最常用 - GridPanel 的 Fill 值 |
UE.BuiltinInt | number | 整数值 |
UE.BuiltinString | string | 字符串 |
UE.BuiltinBool | boolean | 布尔值 |
UE.BuiltinByte | number | 0-255 整数 |
import * as UE from 'ue';
class MyPanel extends React.Component {
// 静态创建(推荐)
private static readonly COLUMN_FILL = (() => {
const arr = UE.NewArray(UE.BuiltinFloat);
arr.Add(1, 1, 1); // 3 列等宽
return arr;
})();
render() {
return (
<GridPanel ColumnFill={MyPanel.COLUMN_FILL}>
{/* items */}
</GridPanel>
);
}
}
const arr = UE.NewArray(UE.BuiltinFloat);
arr.Add(1, 2, 3); // 添加多个值
arr.Get(0); // 获取值(不要用 arr[0]!)
arr.Set(0, 10); // 设置值
arr.Num(); // 获取长度
arr.RemoveAt(0); // 删除
arr.Empty(); // 清空
PuerTS 的 TArray 类型定义使用 [index: number]: never 来阻止直接下标访问,强制使用 .Get()/.Set() 方法,确保类型安全。
npx claudepluginhub 15195999826/lomomarketplace --plugin UE_ReactUMGProvides TypeScript patterns for React: props interfaces, event handlers, hooks, generic components, forwardRef, type-safe context, utility types, discriminated unions.
Builds TanStack Table components using hoisted columns and meta fields for cell callbacks instead of closures to avoid re-renders. Use for data tables with sorting and inline editing.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.