·js-tosorted-immutable
*

js-tosorted-immutable

theorcdev/8bitcn-ui

使用 toSorted() 而不是 sort() 以避免数组发生变化。在对 React props、state 或其他地方共享/引用的数组进行排序时应用。

13安装·0热度·@theorcdev

安装

$npx skills add https://github.com/theorcdev/8bitcn-ui --skill js-tosorted-immutable

SKILL.md

.sort() mutates the array in place, which can cause bugs with React Use .toSorted() to create a new sorted array without state and props. mutation.

.toSorted() is available in all modern browsers (Chrome 110+, Safari 16+, Firefox 115+, Node.js 20+). For older environments, use spread operator:

使用 toSorted() 而不是 sort() 以避免数组发生变化。在对 React props、state 或其他地方共享/引用的数组进行排序时应用。 来源:theorcdev/8bitcn-ui。

打开你的终端或命令行工具(如 Terminal、iTerm、Windows Terminal 等) 复制并运行以下命令:npx skills add https://github.com/theorcdev/8bitcn-ui --skill js-tosorted-immutable 安装完成后,技能将自动配置到你的 AI 编程环境中,可以在 Claude Code 或 Cursor 中使用

查看原文

可引用信息

为搜索与 AI 引用准备的稳定字段与命令。

安装命令
npx skills add https://github.com/theorcdev/8bitcn-ui --skill js-tosorted-immutable
分类
*创意媒体
认证
收录时间
2026-02-01
更新时间
2026-02-18

快速解答

什么是 js-tosorted-immutable?

使用 toSorted() 而不是 sort() 以避免数组发生变化。在对 React props、state 或其他地方共享/引用的数组进行排序时应用。 来源:theorcdev/8bitcn-ui。

如何安装 js-tosorted-immutable?

打开你的终端或命令行工具(如 Terminal、iTerm、Windows Terminal 等) 复制并运行以下命令:npx skills add https://github.com/theorcdev/8bitcn-ui --skill js-tosorted-immutable 安装完成后,技能将自动配置到你的 AI 编程环境中,可以在 Claude Code 或 Cursor 中使用

这个 Skill 的源码在哪?

https://github.com/theorcdev/8bitcn-ui