CodeSampleX

샘플

react 19.2.8: StrictMode

검증된 샘플 — npm react 19.2.8: StrictMode. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: StrictMode is exported as a symbol from react matching…

sha256:bc7b608fee0220bc8876958bcc8c44ca64321465c792194df44cfcfbb22c03a2

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-27

케이스

HOW
목표
verify react.StrictMode in pkg:npm/react@19.2.8
패키지
심벌
  • react.StrictMode
생성일
2026-08-27T15:04:42Z

컨트랙트

  1. StrictMode is exported as a symbol from react matching Symbol.for('react.strict_mode')
  2. StrictMode is distinct from other built-in React symbols including Fragment, Profiler, Suspense, and Activity
  3. React.createElement with StrictMode produces a valid React element with type StrictMode and $$typeof react.transitional.element
  4. StrictMode container element is counted as 1 element by React.Children.count and passes React.Children.only
  5. React.cloneElement preserves StrictMode element type while applying updated key, props, and children
  6. Helper utilities isStrictModeElement, wrapInStrictMode, and cloneStrictMode correctly inspect, wrap, and clone StrictMode elements

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

NOTES.md
# React 19 StrictMode Contract and Behavior

## Prior Search Results

A search for `pkg:npm/react@19.2.8` `react.StrictMode` returned `NO_SAFE_MATCH`.

## Key Behaviors Proven

1. **Symbol Export and Identity**: `React.StrictMode` and named export `StrictMode` are exported from `react` as a `symbol` matching the global `Symbol.for('react.strict_mode')`.
2. **Built-in Type Distinctness**: `StrictMode` is uniquely distinct from other built-in React symbols including `Fragment`, `Profiler`, `Suspense`, and `Activity`.
3. **Element Creation and React 19 Structure**: Calling `React.createElement(StrictMode, ...)` produces a valid React element with `$$typeof` equal to `Symbol.for('react.transitional.element')` and `type` equal to `StrictMode`.
4. **React.Children Utility Compatibility**: `React.Children.count` treats a `StrictMode` element as a single container, `React.Children.only` accepts it, and nested children are accurately accessible via `props.children`.
5. **Element Cloning**: `React.cloneElement` clones `StrictMode` elements preserving the component type while updating props, keys, and children.
6. **Helper Utilities**: `isStrictModeElement`, `wrapInStrictMode`, and `cloneStrictMode` provide safe inspection and transformation wrappers around `StrictMode`.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify react.StrictMode in pkg:npm/react@19.2.8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react@19.2.8
Demonstrate these symbols/APIs:
  - react.StrictMode

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:e08378861a4ed648aa6df052bd44a1cf777c3c773b8d111ed52547d2e6e415d6","contract":["StrictMode is exported as a symbol from react matching Symbol.for('react.strict_mode')","StrictMode is distinct from other built-in React symbols including Fragment, Profiler, Suspense, and Activity","React.createElement with StrictMode produces a valid React element with type StrictMode and $$typeof react.transitional.element","StrictMode container element is counted as 1 element by React.Children.count and passes React.Children.only","React.cloneElement preserves StrictMode element type while applying updated key, props, and children","Helper utilities isStrictModeElement, wrapInStrictMode, and cloneStrictMode correctly inspect, wrap, and clone StrictMode elements"],"goal":"verify react.StrictMode in pkg:npm/react@19.2.8","kind":"HOW","packages":["pkg:npm/react@19.2.8"],"schemaVersion":1,"symbols":["react.StrictMode"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react@19.2.8","symbols":["react.StrictMode"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-react-strict-mode",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-react-strict-mode",
      "version": "1.0.0",
      "dependencies": {
        "react": "19.2.8"
      }
    },
    "node_modules/react": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
      "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "npm-react-strict-mode",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "react": "19.2.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react.StrictMode in pkg:npm/react@19.2.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react@19.2.8"
  ],
  "symbols": [
    "react.StrictMode"
  ]
}
src/index.mjs
import React, { StrictMode } from 'react';

/**
 * Checks whether a given object is a valid React StrictMode element.
 * @param {any} node
 * @returns {boolean}
 */
export function isStrictModeElement(node) {
  return React.isValidElement(node) && node.type === StrictMode;
}

/**
 * Wraps children in a React StrictMode element.
 * @param {any} children
 * @param {object} [props={}]
 * @returns {import('react').ReactElement}
 */
export function wrapInStrictMode(children, props = {}) {
  return React.createElement(StrictMode, props, children);
}

/**
 * Clones a StrictMode element with additional props or new children.
 * @param {import('react').ReactElement} element
 * @param {object} [nextProps={}]
 * @param {any} [nextChildren]
 * @returns {import('react').ReactElement}
 */
export function cloneStrictMode(element, nextProps = {}, nextChildren) {
  if (!isStrictModeElement(element)) {
    throw new TypeError('Expected a React StrictMode element');
  }
  if (nextChildren !== undefined) {
    return React.cloneElement(element, nextProps, nextChildren);
  }
  return React.cloneElement(element, nextProps);
}

export { StrictMode };
export default StrictMode;
test/contract.mjs
import assert from 'node:assert/strict';
import React, { StrictMode } from 'react';
import {
  isStrictModeElement,
  wrapInStrictMode,
  cloneStrictMode
} from '../src/index.mjs';

// 1. Export identity & Symbol definition:
// StrictMode is exported as a symbol from 'react' matching Symbol.for('react.strict_mode')
assert.equal(typeof StrictMode, 'symbol', 'StrictMode should be of type symbol');
assert.equal(StrictMode, React.StrictMode, 'Named export StrictMode matches React.StrictMode');
assert.equal(StrictMode, Symbol.for('react.strict_mode'), 'StrictMode matches Symbol.for("react.strict_mode")');

// Distinct from other built-in React symbols
assert.notEqual(StrictMode, React.Fragment, 'StrictMode is distinct from Fragment');
assert.notEqual(StrictMode, React.Profiler, 'StrictMode is distinct from Profiler');
assert.notEqual(StrictMode, React.Suspense, 'StrictMode is distinct from Suspense');
assert.notEqual(StrictMode, React.Activity, 'StrictMode is distinct from Activity');

// 2. React Element Creation & React 19 Transitional Element structure:
const childText = 'Hello StrictMode';
const element = React.createElement(StrictMode, { key: 'strict-key' }, childText);

assert.ok(React.isValidElement(element), 'Element created with StrictMode is a valid React element');
assert.equal(element.type, StrictMode, 'Element type is StrictMode symbol');
assert.equal(element.key, 'strict-key', 'Element key is preserved');
assert.equal(element.props.children, childText, 'Element props.children contains the child content');
assert.equal(element.$$typeof, Symbol.for('react.transitional.element'), 'React 19 element $$typeof is react.transitional.element');

// 3. React.Children utility behavior:
const multiChildElement = React.createElement(
  StrictMode,
  null,
  React.createElement('span', { key: '1' }, 'Child 1'),
  React.createElement('span', { key: '2' }, 'Child 2')
);

assert.equal(React.Children.count(multiChildElement), 1, 'React.Children.count views StrictMode container as 1 element');
assert.equal(React.Children.only(multiChildElement), multiChildElement, 'React.Children.only succeeds for StrictMode element');

const extractedChildren = React.Children.toArray(multiChildElement.props.children);
assert.equal(extractedChildren.length, 2, 'React.Children.toArray extracts nested children correctly');
assert.equal(extractedChildren[0].props.children, 'Child 1');
assert.equal(extractedChildren[1].props.children, 'Child 2');

// 4. React.cloneElement support:
const clonedElement = React.cloneElement(element, { key: 'cloned-key', 'data-custom': 'strict-val' }, 'New Child');
assert.ok(React.isValidElement(clonedElement), 'Cloned element is valid');
assert.equal(clonedElement.type, StrictMode, 'Cloned element preserves StrictMode type');
assert.equal(clonedElement.key, 'cloned-key', 'Cloned element has updated key');
assert.equal(clonedElement.props['data-custom'], 'strict-val', 'Cloned element includes new custom prop');
assert.equal(clonedElement.props.children, 'New Child', 'Cloned element has updated children');

// 5. Helper module integration (isStrictModeElement, wrapInStrictMode, cloneStrictMode):
assert.equal(isStrictModeElement(element), true, 'isStrictModeElement returns true for StrictMode element');
assert.equal(isStrictModeElement(React.createElement('div', null)), false, 'isStrictModeElement returns false for div element');
assert.equal(isStrictModeElement(null), false, 'isStrictModeElement returns false for null');
assert.equal(isStrictModeElement({}), false, 'isStrictModeElement returns false for plain object');

const wrapped = wrapInStrictMode(React.createElement('p', null, 'Strict Paragraph'), { key: 'p-wrapper' });
assert.ok(isStrictModeElement(wrapped), 'wrapInStrictMode creates valid StrictMode element');
assert.equal(wrapped.key, 'p-wrapper');

const reCloned = cloneStrictMode(wrapped, { key: 'p-wrapper-updated' });
assert.equal(reCloned.key, 'p-wrapper-updated');
assert.ok(isStrictModeElement(reCloned));

assert.throws(
  () => cloneStrictMode(React.createElement('div', null)),
  /Expected a React StrictMode element/,
  'cloneStrictMode throws TypeError when given non-StrictMode element'
);

console.log('All react.StrictMode contract assertions passed successfully!');

오리진 시더

익명