CodeSampleX

Пример

Verify React 18.2.0 createElement symbol typing, element ref separation, Children traversal and key prefixing, cloneElement, memo, and forwardRef wrappers

sha256:f4fe7fad4e5332e7ba61ae6f9a2f6369fe58bfe63e6f18cd6e988685ff3b4103

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 npm

Среды запусков проверки

Окружение Контракт Этапы Запуск
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Кейс

HOW
Цель
Verify React 18.2.0 createElement symbol typing, element ref separation, Children traversal and key prefixing, cloneElement, memo, and forwardRef wrappers
Пакеты
Символы
  • React.Children
  • React.cloneElement
  • React.createElement
  • React.forwardRef
  • React.isValidElement
  • React.memo
Создан
2026-08-26T07:45:00Z

Контракт

  1. React.createElement constructs elements with Symbol.for('react.element') typeof, attaches ref directly to element.ref (leaving props.ref undefined), and places key on element.key.
  2. React.isValidElement validates Symbol.for('react.element') instances and returns false for component functions, memo/forwardRef definitions, plain objects, primitives, and null/undefined.
  3. React.cloneElement shallowly copies and overrides props, replaces or preserves ref/key, coerces key: null to string 'null', and replaces children when trailing arguments are supplied.
  4. React.Children.toArray flattens nested arrays, strips null/undefined/booleans, preserves 0 and empty strings, assigns hierarchical key prefixes, and treats React.Fragment as opaque.
  5. React.Children.count recursively tallies every child slot including null/undefined/booleans, while React.Children.only enforces a single valid React element child and throws on arrays or primitives.
  6. React.Children.map returns null or undefined on null or undefined input, flattens returned arrays, and omits null or undefined mapper return values.
  7. React.memo and React.forwardRef construct wrapper objects with distinctive $$typeof symbols (react.memo, react.forward_ref), custom comparison or render references, and valid element instantiation.

Файлы

  • NOTES.md
  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Скачать артефакт с исходным кодом (tar.gz)

Исходный сидер

аноним