React Quick Start examples fail at runtime: Renderer must be wrapped in JSONUIProvider

Open Beginner friendly
#443 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@jitui-123 is already working on this.

Since Oct 29, 2026.

  • #445 by @jitui-123 — open

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript

Research direction

Read the React examples at lines 119, 188, and 280 of the root README.md, then check the Solid example at lines 231–247 for the provider pattern. Update the three React examples to wrap Renderer in JSONUIProvider, using the working version in the issue as a guide. Done when each documented React snippet includes the required provider.

Written by the indexing model from the issue text.

Description

Summary

The React Quick Start in the root README.md and the @json-render/react usage examples render <Renderer> without any provider. Copying these snippets verbatim crashes at runtime:

Error: useVisibility must be used within a VisibilityProvider
    at useVisibility (...)
    at ReactiveElementRenderer (...)

Where

Root README.md:

  • Line 119 — React Quick Start (Renderer in a Dashboard component, no provider)
  • Line 188 — React renderer section, "That's it" example
  • Line 280 — shadcn/ui section

The Solid section (line 231–247) is the only renderer example that wraps <JSONUIProvider> correctly, which suggests this was known but never backported to the React examples.

Why it fails

Renderer calls useVisibility(), which throws unless a VisibilityProvider is above it:

throw new Error("useVisibility must be used within a VisibilityProvider");

JSONUIProvider is what supplies it. Its implementation nests the required providers:

<StateProvider>
  <VisibilityProvider>
    <ValidationProvider>
      <ActionProvider>
        <FunctionsContext.Provider>
          <DirectivesContext.Provider>
            {children}
            <ConfirmationDialogManager />

So the provider is not optional for React — only for renderers whose README already shows it.

Reproduction

import { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/react/schema";
import { defineRegistry, Renderer } from "@json-render/react";

const catalog = defineCatalog(schema, { components: { /* ... */ }, actions: {} });
const { registry } = defineRegistry(catalog, { components: { /* ... */ } });

const spec = { root: "a", elements: { a: { type: "Card", props: {}, children: [] } } };

// Exactly as documented
<Renderer spec={spec} registry={registry} />;
// -> Error: useVisibility must be used within a VisibilityProvider

Working version

import { defineRegistry, Renderer, JSONUIProvider } from "@json-render/react";

<JSONUIProvider registry={registry} initialState={spec.state ?? {}}>
  <Renderer spec={spec} registry={registry} />
</JSONUIProvider>

Environment

  • @json-render/core 0.21.3
  • @json-render/react 0.21.3
  • @json-render/shadcn 0.21.3
  • react / react-dom 19
  • zod 4
  • Vite 8, Node 26

Suggested fix

Update the three README snippets to include <JSONUIProvider>, or add a one-line note in the Quick Start that Renderer must be wrapped in a provider. A provider-missing error that names the required component (e.g. "wrap <Renderer> in <JSONUIProvider>") would also save a lot of time for newcomers.


This is not a bug report — the provider design is reasonable. The issue is that the primary React examples in the README don't work as written.

Dominant language
TypeScript
Stars
20k
Forks
1.1k
Avg merge
1d 18h
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel-labs/json-render

All issues in vercel-labs/json-render

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.