CodeSampleX

샘플

react-is 19.2.8: StrictMode

검증된 샘플 — npm react-is 19.2.8: StrictMode. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: react-is exports StrictMode matching…

sha256:6cc6fd0947db7a940c02bbbd4555f23a8937325ba746d6ab276deb327af12030

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

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-06

케이스

HOW
목표
verify react-is.StrictMode in pkg:npm/react-is@19.2.8
패키지
심벌
  • react-is.StrictMode
생성일
2026-09-06T09:12:31Z

컨트랙트

  1. react-is exports StrictMode matching Symbol.for('react.strict_mode')
  2. isValidElementType identifies StrictMode as a valid React element type
  3. isStrictMode detects valid React 19 StrictMode elements
  4. isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives
  5. typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements

파일

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

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

소스

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-is.StrictMode in pkg:npm/react-is@19.2.8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-is@19.2.8
Demonstrate these symbols/APIs:
  - react-is.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:dc5c67055bc50f8fd84bcde20ddfc0cee8abde34ec9d865fe5e08bdc59a99def","contract":["react-is exports StrictMode matching Symbol.for('react.strict_mode')","isValidElementType identifies StrictMode as a valid React element type","isStrictMode detects valid React 19 StrictMode elements","isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives","typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements"],"goal":"verify react-is.StrictMode in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.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-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.StrictMode"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-strictmode",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-strictmode",
      "version": "1.0.0",
      "dependencies": {
        "react-is": "19.2.8"
      }
    },
    "node_modules/react-is": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.8.tgz",
      "integrity": "sha512-s5un28nYxKJw5gvUHyW5PCC28CvBqLu9r3cWgzHT4Vo/5fqqkFcdRYsGcKf50WMPpjjFZS5d76fn3YCo2njKwQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-react-is-strictmode",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-is.StrictMode in React 19",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "react-is": "19.2.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.StrictMode in pkg:npm/react-is@19.2.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@19.2.8"
  ],
  "symbols": [
    "react-is.StrictMode"
  ]
}
src/index.js
import {
  StrictMode,
  isStrictMode,
  typeOf,
  isValidElementType,
  Element,
} from 'react-is';

export { StrictMode, Element };

/**
 * Creates a React 19 element representation.
 *
 * @param {*} type - The element type.
 * @param {Object} [props={}] - Element properties.
 * @returns {Object} React element object.
 */
export function createElement(type, props = {}) {
  return {
    $$typeof: Element || Symbol.for('react.transitional.element'),
    type,
    props,
    key: null,
    ref: null,
  };
}

/**
 * Creates a React 19 StrictMode element representation.
 *
 * @param {*} [children] - Children to include in props.
 * @returns {Object} React StrictMode element object.
 */
export function createStrictModeElement(children) {
  const props = children !== undefined ? { children } : {};
  return createElement(StrictMode, props);
}

/**
 * Checks whether a given object is a React StrictMode element.
 *
 * @param {*} value - The value to test.
 * @returns {boolean} True if the value is a StrictMode element.
 */
export function checkIsStrictMode(value) {
  return isStrictMode(value);
}

/**
 * Checks whether a given type is a valid React element type.
 *
 * @param {*} type - The type to test.
 * @returns {boolean} True if the type is valid.
 */
export function checkIsValidElementType(type) {
  return isValidElementType(type);
}

/**
 * Inspects the React type of a given value.
 *
 * @param {*} value - The value to inspect.
 * @returns {*|undefined} Type symbol or undefined.
 */
export function inspectTypeOf(value) {
  return typeOf(value);
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  StrictMode,
  Element,
  createElement,
  createStrictModeElement,
  checkIsStrictMode,
  checkIsValidElementType,
  inspectTypeOf,
} from '../src/index.js';
import reactIs from 'react-is';

// Contract 1: react-is exports StrictMode matching Symbol.for('react.strict_mode')
assert.equal(typeof StrictMode, 'symbol', 'StrictMode must be a symbol');
assert.equal(StrictMode, Symbol.for('react.strict_mode'), 'StrictMode must match Symbol.for("react.strict_mode")');
assert.equal(reactIs.StrictMode, StrictMode, 'Default import StrictMode must match named import StrictMode');

// Contract 2: isValidElementType identifies StrictMode as a valid React element type
assert.equal(checkIsValidElementType(StrictMode), true, 'StrictMode must be recognized as a valid element type');
assert.equal(reactIs.isValidElementType(StrictMode), true, 'react-is.isValidElementType must return true for StrictMode');
assert.equal(checkIsValidElementType('div'), true, 'String tag must be a valid element type');
assert.equal(checkIsValidElementType(() => null), true, 'Function component must be a valid element type');
assert.equal(checkIsValidElementType(123), false, 'Number must not be a valid element type');
assert.equal(checkIsValidElementType(null), false, 'null must not be a valid element type');
assert.equal(checkIsValidElementType(undefined), false, 'undefined must not be a valid element type');

// Contract 3: isStrictMode detects valid React 19 StrictMode elements
const strictModeWithChildren = createStrictModeElement(['child1', 'child2']);
assert.equal(checkIsStrictMode(strictModeWithChildren), true, 'StrictMode element with children must be detected by checkIsStrictMode');
assert.equal(reactIs.isStrictMode(strictModeWithChildren), true, 'StrictMode element with children must be detected by reactIs.isStrictMode');

const emptyStrictMode = createStrictModeElement();
assert.equal(checkIsStrictMode(emptyStrictMode), true, 'Empty StrictMode element must be detected by checkIsStrictMode');
assert.equal(reactIs.isStrictMode(emptyStrictMode), true, 'Empty StrictMode element must be detected by reactIs.isStrictMode');

// Contract 4: isStrictMode returns false for StrictMode symbol itself, non-strictmode elements, and primitives
assert.equal(checkIsStrictMode(StrictMode), false, 'StrictMode symbol itself is not an element instance');
assert.equal(reactIs.isStrictMode(StrictMode), false, 'StrictMode symbol itself must return false from isStrictMode');

const divElement = createElement('div', { id: 'root' });
assert.equal(checkIsStrictMode(divElement), false, 'Plain div element must not be identified as a StrictMode');
assert.equal(reactIs.isStrictMode(divElement), false, 'Plain div element must return false from isStrictMode');

const fragmentElement = createElement(Symbol.for('react.fragment'));
assert.equal(checkIsStrictMode(fragmentElement), false, 'Fragment element must not be identified as a StrictMode');

const legacyStrictMode = {
  $$typeof: Symbol.for('react.element'),
  type: StrictMode,
  props: {},
  key: null,
  ref: null,
};
assert.equal(checkIsStrictMode(legacyStrictMode), false, 'Legacy React element $$typeof is not recognized by React 19 react-is');

assert.equal(checkIsStrictMode(null), false, 'null must return false');
assert.equal(checkIsStrictMode(undefined), false, 'undefined must return false');
assert.equal(checkIsStrictMode({}), false, 'Plain object must return false');
assert.equal(checkIsStrictMode('react.strict_mode'), false, 'String must return false');
assert.equal(checkIsStrictMode(42), false, 'Number must return false');

// Contract 5: typeOf returns StrictMode symbol for valid strictmode elements and undefined for non-elements
assert.equal(inspectTypeOf(strictModeWithChildren), StrictMode, 'inspectTypeOf must return StrictMode symbol for strictmode element');
assert.equal(reactIs.typeOf(strictModeWithChildren), StrictMode, 'reactIs.typeOf must return StrictMode symbol for strictmode element');
assert.equal(inspectTypeOf(emptyStrictMode), StrictMode, 'inspectTypeOf must return StrictMode symbol for empty strictmode element');

assert.equal(inspectTypeOf(divElement), Element, 'inspectTypeOf returns Element symbol for plain element');
assert.equal(inspectTypeOf(fragmentElement), Symbol.for('react.fragment'), 'inspectTypeOf returns Fragment symbol');
assert.equal(inspectTypeOf(StrictMode), undefined, 'inspectTypeOf returns undefined for StrictMode symbol');
assert.equal(inspectTypeOf(null), undefined, 'inspectTypeOf returns undefined for null');
assert.equal(inspectTypeOf(undefined), undefined, 'inspectTypeOf returns undefined for undefined');
assert.equal(inspectTypeOf({}), undefined, 'inspectTypeOf returns undefined for plain object');
assert.equal(inspectTypeOf(legacyStrictMode), undefined, 'inspectTypeOf returns undefined for legacy element');

console.log('All react-is.StrictMode contract assertions passed.');

오리진 시더

익명