샘플
react-dom 19.0.0: createRoot
검증된 샘플 — npm react-dom 19.0.0: createRoot. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: createRoot is exported as a function from…
sha256:ff9a79a4b52513040c2cde5860e1b49d7a36b9ddbe5ef9ec72ba5256ea5fb8b8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-dom.createRoot in pkg:npm/react-dom@19.0.0
- 패키지
- 심벌
-
- react-dom.createRoot
- 환경
- node 22.23.2
- 생성일
- 2026-09-06T20:59:50Z
컨트랙트
- createRoot is exported as a function from react-dom/client
- createRoot(null) and createRoot({}) throw Error 'Target container is not a DOM element.'
- createRoot(container) returns a root object with render and unmount methods
- root.render(element) renders React elements into the target DOM container
- root.unmount() unmounts the rendered tree and clears the container contents
- createRoot accepts optional configuration including identifierPrefix for React useId hooks
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
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-dom.createRoot in pkg:npm/react-dom@19.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/react-dom@19.0.0
Demonstrate these symbols/APIs:
- react-dom.createRoot
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.
{"case":{"caseId":"case:sha256:144ef3bfe09de50745bea4980613d4261bd387e99491bdf6858a8b3f7d0a6bc8","contract":["createRoot is exported as a function from react-dom/client","createRoot(null) and createRoot({}) throw Error 'Target container is not a DOM element.'","createRoot(container) returns a root object with render and unmount methods","root.render(element) renders React elements into the target DOM container","root.unmount() unmounts the rendered tree and clears the container contents","createRoot accepts optional configuration including identifierPrefix for React useId hooks"],"goal":"verify react-dom.createRoot in pkg:npm/react-dom@19.0.0","kind":"HOW","packages":["pkg:npm/react-dom@19.0.0"],"schemaVersion":1,"symbols":["react-dom.createRoot"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-dom@19.0.0"],"schemaVersion":1,"subject":"pkg:npm/react-dom@19.0.0","symbols":["react-dom.createRoot"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-react-dom-createroot",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-react-dom-createroot",
"version": "1.0.0",
"dependencies": {
"react": "19.0.0",
"react-dom": "19.0.0"
}
},
"node_modules/react": {
"version": "19.0.0",
"resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz",
"integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-dom": {
"version": "19.0.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0.tgz",
"integrity": "sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==",
"license": "MIT",
"dependencies": {
"scheduler": "^0.25.0"
},
"peerDependencies": {
"react": "^19.0.0"
}
},
"node_modules/scheduler": {
"version": "0.25.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz",
"integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==",
"license": "MIT"
}
}
}
{
"name": "sample-react-dom-createroot",
"version": "1.0.0",
"private": true,
"dependencies": {
"react": "19.0.0",
"react-dom": "19.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify react-dom.createRoot in pkg:npm/react-dom@19.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/react-dom@19.0.0"
],
"symbols": [
"react-dom.createRoot"
]
}
import { createRoot } from "react-dom/client";
/**
* Creates and mounts a React root into a DOM container element.
*
* @param {Element|Document|DocumentFragment} container
* @param {import("react").ReactNode} element
* @param {object} [options]
* @returns {{ root: object, unmount: () => void }}
*/
export function createAndMountRoot(container, element, options = {}) {
const root = createRoot(container, options);
root.render(element);
return {
root,
unmount: () => root.unmount()
};
}
export { createRoot };
import assert from "node:assert/strict";
import React from "react";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { createAndMountRoot } from "../src/index.mjs";
// Setup minimal offline DOM environment for Node.js
class Node {}
class Element extends Node {}
class HTMLElement extends Element {}
class HTMLIFrameElement extends HTMLElement {}
class Document extends Node {}
class DocumentFragment extends Node {}
const window = {
event: undefined,
Node,
Element,
HTMLElement,
HTMLIFrameElement,
Document,
DocumentFragment
};
globalThis.window = window;
globalThis.Node = Node;
globalThis.Element = Element;
globalThis.HTMLElement = HTMLElement;
globalThis.HTMLIFrameElement = HTMLIFrameElement;
globalThis.Document = Document;
globalThis.DocumentFragment = DocumentFragment;
function createMockDocument() {
const docListeners = new Map();
const doc = {
nodeType: 9,
nodeName: "#document",
activeElement: null,
defaultView: window,
createElement(tag) {
const elListeners = new Map();
const elChildren = [];
const el = {
nodeType: 1,
nodeName: tag.toUpperCase(),
tagName: tag.toUpperCase(),
childNodes: elChildren,
children: elChildren,
style: {},
ownerDocument: doc,
setAttribute(k, v) { this[k] = v; },
getAttribute(k) { return this[k] || null; },
appendChild(child) { elChildren.push(child); return child; },
removeChild(child) {
const idx = elChildren.indexOf(child);
if (idx >= 0) elChildren.splice(idx, 1);
return child;
},
insertBefore(newChild, refChild) {
const idx = elChildren.indexOf(refChild);
if (idx >= 0) elChildren.splice(idx, 0, newChild);
else elChildren.push(newChild);
return newChild;
},
addEventListener(event, handler) {
if (!elListeners.has(event)) elListeners.set(event, []);
elListeners.get(event).push(handler);
},
removeEventListener(event, handler) {
if (elListeners.has(event)) {
const arr = elListeners.get(event);
const idx = arr.indexOf(handler);
if (idx >= 0) arr.splice(idx, 1);
}
}
};
return el;
},
createTextNode(text) {
return {
nodeType: 3,
nodeName: "#text",
nodeValue: String(text),
textContent: String(text),
ownerDocument: doc
};
},
createComment(data) {
return {
nodeType: 8,
nodeName: "#comment",
nodeValue: String(data),
ownerDocument: doc
};
},
addEventListener(event, handler) {
if (!docListeners.has(event)) docListeners.set(event, []);
docListeners.get(event).push(handler);
},
removeEventListener(event, handler) {
if (docListeners.has(event)) {
const arr = docListeners.get(event);
const idx = arr.indexOf(handler);
if (idx >= 0) arr.splice(idx, 1);
}
}
};
window.document = doc;
return doc;
}
const doc = createMockDocument();
globalThis.document = doc;
// 1. Symbol availability: createRoot is exported as a function from react-dom/client
assert.strictEqual(typeof createRoot, "function", "createRoot must be exported as a function");
// 2. Error handling: createRoot(null) and createRoot({}) throw Error 'Target container is not a DOM element.'
assert.throws(
() => createRoot(null),
/Target container is not a DOM element/,
"createRoot(null) must throw Target container is not a DOM element"
);
assert.throws(
() => createRoot({}),
/Target container is not a DOM element/,
"createRoot({}) must throw Target container is not a DOM element"
);
// 3. Create root on valid DOM element: createRoot(container) returns a root object with render and unmount methods
const container = doc.createElement("div");
const root = createRoot(container);
assert.strictEqual(typeof root.render, "function", "root must have a render method");
assert.strictEqual(typeof root.unmount, "function", "root must have an unmount method");
// 4. Render element: root.render(element) renders React elements into the target DOM container
flushSync(() => {
root.render(React.createElement("span", { id: "test-node" }, "React 19.0.0 createRoot verified"));
});
assert.strictEqual(container.childNodes.length, 1, "Container should have 1 child node after render");
assert.strictEqual(container.childNodes[0].tagName, "SPAN", "Rendered child tag should be SPAN");
// 5. Unmount root: root.unmount() unmounts the rendered tree and clears the container contents
flushSync(() => {
root.unmount();
});
assert.strictEqual(container.childNodes.length, 0, "Container should have 0 children after unmount");
// 6. Options support: createRoot accepts optional configuration including identifierPrefix for React useId hooks
const optContainer = doc.createElement("div");
const optRoot = createRoot(optContainer, {
identifierPrefix: "custom-prefix-"
});
function AppWithId() {
const generatedId = React.useId();
return React.createElement("div", { id: generatedId }, "Component with ID");
}
flushSync(() => {
optRoot.render(React.createElement(AppWithId));
});
assert.strictEqual(optContainer.childNodes.length, 1, "Option container should have 1 child");
assert.ok(
optContainer.childNodes[0].id && optContainer.childNodes[0].id.includes("custom-prefix-"),
"Generated ID should contain identifierPrefix"
);
flushSync(() => {
optRoot.unmount();
});
assert.strictEqual(optContainer.childNodes.length, 0, "Option container should be empty after unmount");
// 7. Helper verification
const helperContainer = doc.createElement("div");
let helperHandle;
flushSync(() => {
helperHandle = createAndMountRoot(
helperContainer,
React.createElement("p", null, "Mounted via helper")
);
});
assert.strictEqual(helperContainer.childNodes.length, 1, "Helper container should have 1 child");
flushSync(() => {
helperHandle.unmount();
});
assert.strictEqual(helperContainer.childNodes.length, 0, "Helper container should be empty after unmount");
console.log("All contract assertions passed successfully.");
오리진 시더
익명