Repository navigation
Conversation
The React Quick Start rendered <Renderer> on its own, which throws at
runtime:
Error: useVisibility must be used within a VisibilityProvider
Renderer reads from the state, visibility, validation, and action
contexts that JSONUIProvider supplies, so the provider is required.
Updates the three React snippets in the README (Quick Start, React
renderer section, shadcn/ui section) and the React Native snippet, which
had the same gap. The Solid example was already correctly wrapped.
Refs vercel-labs#443
Contributor
|
@jitui-123 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
| const { registry } = defineRegistry(catalog, { components }); | ||
| <Renderer spec={spec} registry={registry} />; | ||
|
|
||
| <JSONUIProvider registry={registry} initialState={spec.state ?? {}}> |
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The React examples in the README render
<Renderer>without a provider, which throws at runtime. This wraps them in<JSONUIProvider>and adds a short note on why the provider is required.Refs #443.
Changed
Every snippet that renders
<Renderer>for React now includes the provider import and wrapper:The Solid example already wrapped correctly and is unchanged, as are the Vue and Svelte sections where
<Renderer>appears only in a comment showing template usage.Why the provider is required
RenderercallsuseVisibility(), which throws unless aVisibilityProvideris above it.JSONUIProvideris what supplies that context, along with state, validation, and actions:The imported
JSONUIProvideris available from both@json-render/reactand@json-render/react-native.Verification
Checked out the branch with
@json-render/core,@json-render/react, and@json-render/shadcnat 0.21.3, React 19, and Zod 4:<Renderer spec registry />throwsuseVisibility must be used within a VisibilityProvider.<Renderer>usages — none left outside comments.Happy to adjust the wording or drop the React Native change if you'd rather keep this PR to the three React snippets.