From f7dc93821231c1f06b93eb7c7945712e353e7739 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Sep 2026 16:40:43 +0000 Subject: [PATCH] docs(vscode-extension): state what Export to React actually does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page described the `ObjectUI: Export to React` command in two ways it does not behave. 1. The Usage list said "React component code is copied to clipboard". It is not: `exportToReact()` opens an untitled document with `language: 'typescriptreact'`, shows it, and shows the message `React component generated! Save it to a .tsx file.` The identifier `clipboard` does not occur anywhere under `packages/vscode-extension/src`. The list now states the untitled `typescriptreact` tab, the message, and that nothing is written to disk or to the clipboard. 2. The Output Example imported only `SchemaRenderer` and so omitted `import '@object-ui/components';`, which is load-bearing: that package declares `sideEffects: true` and its barrel is what registers the default renderers, so a reader who copied the documented example instead of running the command got a SchemaRenderer with nothing registered. The Output Example is now the command's real product, byte for byte: the template was read out of `generateReactComponent()` the way `export-to-react-preamble.test.ts` reads it and evaluated against the example schema this page already taught. The absent `import React from 'react'` stays absent — objectui#7862 removed it deliberately, and the template's own comment explaining why is reproduced with the rest of the product. Docs only; no gate binds the page to the template (that is objectui#7976). Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr --- content/docs/utilities/vscode-extension.mdx | 31 +++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/content/docs/utilities/vscode-extension.mdx b/content/docs/utilities/vscode-extension.mdx index e324e4a8c4..52d49175db 100644 --- a/content/docs/utilities/vscode-extension.mdx +++ b/content/docs/utilities/vscode-extension.mdx @@ -76,23 +76,42 @@ Converts the schema to a React component. **Usage:** 1. Open a schema file 2. Run command -3. React component code is copied to clipboard +3. The generated component opens in a **new untitled editor tab**, with its + language set to `typescriptreact` +4. VS Code shows `React component generated! Save it to a .tsx file.` — nothing + is written to disk and nothing is put on your clipboard, so save that tab + yourself **Output Example:** +This is the file the command produces — your exported schema comes back verbatim +as the `schema` constant, and both imports are part of the output. +`import '@object-ui/components'` is load-bearing: importing the package is what +registers the default renderers, so a file that drops it renders nothing. + ```typescript -import { SchemaRenderer } from '@object-ui/react' +// No React import: under the automatic JSX runtime ("jsx": "react-jsx", +// what a new Vite or Next project is configured with) nothing here reads that +// identifier, so it compiles as an unused local. Add the import back only if +// this file is built with the classic "jsx": "react" transform. +import { SchemaRenderer } from '@object-ui/react'; +// Importing the package registers every default renderer as a side effect — +// there is no separate registration call. +import '@object-ui/components'; const schema = { "type": "div", "className": "p-4", "children": [ - { "type": "h1", "children": "Hello World" } + { + "type": "h1", + "children": "Hello World" + } ] -} +}; -export default function MyComponent() { - return +export default function GeneratedComponent() { + return ; } ```