CodeSampleX

サンプル

react-is 17.0.2: Memo

検証済みサンプル — npm react-is 17.0.2: Memo. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: Memo exports the react.memo symbol identifier in React 17

sha256:95efd4aac94b6fd2679e88ba4d29b9d54e1660aa58f713712919b53e9f0bb74c

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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.Memo in pkg:npm/react-is@17.0.2
パッケージ
シンボル
  • react-is.Memo
作成日
2026-09-06T08:32:12Z

コントラクト

  1. Memo exports the react.memo symbol identifier in React 17
  2. isMemo returns true for React 17 elements wrapping memo component types
  3. typeOf returns Memo symbol for valid memo elements
  4. isMemo returns false for React 19 transitional element symbols
  5. isMemo returns false for unmounted memo component definition objects
  6. isValidElementType recognizes memo component definitions
  7. isMemo returns false for standard DOM elements and primitives

ファイル

  • 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.Memo in pkg:npm/react-is@17.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-is@17.0.2
Demonstrate these symbols/APIs:
  - react-is.Memo

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:53e507641f944a15e9d75eb4dbeb6da8ca0468f7601fae57e8c930fd589302e1","contract":["Memo exports the react.memo symbol identifier in React 17","isMemo returns true for React 17 elements wrapping memo component types","typeOf returns Memo symbol for valid memo elements","isMemo returns false for React 19 transitional element symbols","isMemo returns false for unmounted memo component definition objects","isValidElementType recognizes memo component definitions","isMemo returns false for standard DOM elements and primitives"],"goal":"verify react-is.Memo in pkg:npm/react-is@17.0.2","kind":"HOW","packages":["pkg:npm/react-is@17.0.2"],"schemaVersion":1,"symbols":["react-is.Memo"]},"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@17.0.2"],"schemaVersion":1,"subject":"pkg:npm/react-is@17.0.2","symbols":["react-is.Memo"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-memo",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-memo",
      "version": "1.0.0",
      "dependencies": {
        "react-is": "17.0.2"
      }
    },
    "node_modules/react-is": {
      "version": "17.0.2",
      "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
      "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-react-is-memo",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-is.Memo in React 17",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "react-is": "17.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.Memo in pkg:npm/react-is@17.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@17.0.2"
  ],
  "symbols": [
    "react-is.Memo"
  ]
}
src/index.js
import { Memo, isMemo, typeOf, isValidElementType } from 'react-is';

/**
 * Symbol used by React 17 for elements.
 */
export const REACT_ELEMENT_TYPE = Symbol.for('react.element');

/**
 * Symbol used by React 19 for transitional elements (not recognized by React 17).
 */
export const REACT_TRANSITIONAL_ELEMENT_TYPE = Symbol.for('react.transitional.element');

/**
 * Check if the provided value is a React memo element using react-is.
 *
 * @param {*} value - Value to inspect.
 * @returns {boolean} True if the value is a memo element.
 */
export function checkIsMemo(value) {
  return isMemo(value);
}

/**
 * Check if the provided value is a valid memo component definition.
 *
 * @param {*} value - Value to inspect.
 * @returns {boolean} True if the value is a valid memo component type.
 */
export function checkIsValidMemoType(value) {
  return (
    typeof value === 'object' &&
    value !== null &&
    value.$$typeof === Memo &&
    isValidElementType(value)
  );
}

/**
 * Create a mock React 17 element wrapping a memo component.
 *
 * @param {Function} [renderFn] - Inner render component.
 * @returns {object} Mock element.
 */
export function createMemoElement(renderFn = () => null) {
  const memoType = {
    $$typeof: Memo,
    type: renderFn,
    compare: null,
  };
  return {
    $$typeof: REACT_ELEMENT_TYPE,
    type: memoType,
    props: {},
    key: null,
    ref: null,
  };
}

/**
 * Create a mock React 19 transitional element wrapping a memo component.
 *
 * @param {Function} [renderFn] - Inner render component.
 * @returns {object} Mock transitional element.
 */
export function createTransitionalMemoElement(renderFn = () => null) {
  const memoType = {
    $$typeof: Memo,
    type: renderFn,
    compare: null,
  };
  return {
    $$typeof: REACT_TRANSITIONAL_ELEMENT_TYPE,
    type: memoType,
    props: {},
    key: null,
    ref: null,
  };
}

export {
  Memo,
  isMemo,
  typeOf,
  isValidElementType,
};
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Memo,
  isMemo,
  typeOf,
  isValidElementType,
  REACT_ELEMENT_TYPE,
  REACT_TRANSITIONAL_ELEMENT_TYPE,
  checkIsMemo,
  checkIsValidMemoType,
  createMemoElement,
  createTransitionalMemoElement,
} from '../src/index.js';

// 1. Symbol and Function exports verification
assert.equal(typeof Memo, 'symbol', 'Memo should export a symbol');
assert.equal(Memo, Symbol.for('react.memo'), 'Memo must match Symbol.for("react.memo")');
assert.equal(typeof isMemo, 'function', 'isMemo should be a function');
assert.equal(typeof typeOf, 'function', 'typeOf should be a function');
assert.equal(typeof isValidElementType, 'function', 'isValidElementType should be a function');
assert.equal(typeof checkIsMemo, 'function', 'checkIsMemo helper should be a function');
assert.equal(typeof checkIsValidMemoType, 'function', 'checkIsValidMemoType helper should be a function');

// 2. React 17 Memo Element verification
const memoElem = createMemoElement(() => null);
assert.equal(isMemo(memoElem), true, 'isMemo must return true for React 17 memo elements');
assert.equal(checkIsMemo(memoElem), true, 'checkIsMemo helper must return true for React 17 memo elements');
assert.equal(typeOf(memoElem), Memo, 'typeOf must return Memo symbol for valid memo elements');

// 3. React 19 Transitional Element verification (not recognized in React 17)
const transitionalMemoElem = createTransitionalMemoElement(() => null);
assert.equal(isMemo(transitionalMemoElem), false, 'React 17 react-is does not match React 19 transitional element symbol for isMemo');
assert.notEqual(typeOf(transitionalMemoElem), Memo, 'typeOf does not return Memo for React 19 transitional element symbols');

// 4. Raw Memo Component Type Object (unmounted definition) verification
const rawMemoComponent = {
  $$typeof: Memo,
  type: () => null,
  compare: null,
};
assert.equal(isMemo(rawMemoComponent), false, 'isMemo must return false for raw memo component definitions without element envelope');
assert.equal(isValidElementType(rawMemoComponent), true, 'isValidElementType must recognize raw memo component definitions');
assert.equal(checkIsValidMemoType(rawMemoComponent), true, 'checkIsValidMemoType helper must return true for valid memo component types');

// 5. Negative assertions for non-memo elements and invalid values
const plainElement = {
  $$typeof: REACT_ELEMENT_TYPE,
  type: 'div',
  props: {},
  key: null,
  ref: null,
};
assert.equal(isMemo(plainElement), false, 'plain element is not a memo element');
assert.equal(isMemo(null), false, 'null is not a memo element');
assert.equal(isMemo(undefined), false, 'undefined is not a memo element');
assert.equal(isMemo({}), false, 'empty object is not a memo element');
assert.equal(isMemo('div'), false, 'primitive string is not a memo element');
assert.equal(isMemo(123), false, 'primitive number is not a memo element');
assert.equal(isMemo(() => null), false, 'plain function component is not a memo element');
assert.equal(isMemo(Memo), false, 'Memo symbol itself is not a memo element');

// 6. isValidElementType negative checks
assert.equal(isValidElementType(null), false, 'isValidElementType returns false for null');
assert.equal(isValidElementType(undefined), false, 'isValidElementType returns false for undefined');
assert.equal(isValidElementType(Memo), false, 'isValidElementType returns false for raw Memo symbol');

console.log('Contract tests passed successfully.');

オリジンシーダー

匿名