-
Notifications
You must be signed in to change notification settings - Fork 2
Fix SSR failure: make useDataScope context-optional #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d317ceb
8a395ad
8b5e099
3f1fac4
f31af0d
080df1e
72093f9
1f4ab89
829cb97
2ce8dd9
63799e0
aca74ed
ba65bac
6d32093
d37797f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,8 +20,10 @@ import { | |||||
| import { cn } from '../../lib/utils'; | ||||||
|
|
||||||
| export const SimpleTableRenderer = ({ schema, className }: any) => { | ||||||
| const data = useDataScope(schema.bind); | ||||||
| const columns = schema.props?.columns || []; | ||||||
| // Try to get data from binding first, then fall back to inline data | ||||||
| const boundData = useDataScope(schema.bind); | ||||||
| const data = boundData || schema.data || schema.props?.data || []; | ||||||
| const columns = schema.columns || schema.props?.columns || []; | ||||||
|
Comment on lines
+23
to
+26
|
||||||
| const columns = schema.columns || schema.props?.columns || []; | |
| const columns = schema.columns ?? []; |
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Rule #0 of the coding guidelines, all component schemas must strictly follow definitions in @objectstack/spec. The standard TableColumn interface (defined in packages/types/src/data-display.ts:203-260) uses header and accessorKey as the canonical property names, not label and key.
While adding fallback support for key/label provides backwards compatibility, this creates ambiguity and deviates from the spec. The documentation at content/docs/components/complex/table.mdx:14-20 and examples in packages/components/src/stories-json/data-table.stories.tsx:21-24 consistently use header and accessorKey.
Consider either:
- Removing the
key/labelaliases and only supporting the spec-compliantaccessorKey/headerproperties, or - Documenting this deviation from the spec with a clear migration path if these are legacy properties being phased out.
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Rule #0 of the coding guidelines, all component schemas must strictly follow definitions in @objectstack/spec. The standard TableColumn interface uses accessorKey and header as the canonical property names, not key and label.
The fallback to col.key and col.accessorKey creates ambiguity. The code should consistently use the spec-compliant property names. Consider removing support for the non-standard key property or documenting why this deviation from the spec is necessary.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,7 @@ export default defineConfig({ | |
| ], | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,4 +46,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,4 +41,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,4 +36,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,4 +36,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,8 +35,9 @@ export const useSchemaContext = () => { | |||||||
| }; | ||||||||
|
|
||||||||
| export const useDataScope = (path?: string) => { | ||||||||
| const { dataSource } = useSchemaContext(); | ||||||||
| if (!path) return dataSource; | ||||||||
| const context = useContext(SchemaRendererContext); | ||||||||
| const dataSource = context?.dataSource; | ||||||||
| if (!dataSource || !path) return dataSource; | ||||||||
|
||||||||
| if (!dataSource || !path) return dataSource; | |
| if (!dataSource) return undefined; | |
| if (!path) return dataSource; |
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavioral change to make useDataScope context-optional lacks test coverage. While the change fixes SSR issues, there are no tests verifying:
- The hook returns
undefinedwhen context is missing (new behavior) - The hook still works correctly when context is available
- Path resolution works correctly with the optional context
- Edge case: what happens when context exists but
dataSourceisundefined
The repository has test infrastructure (packages/react/src/__tests__/) but no coverage for this critical hook. This is a significant behavioral change that should be tested to prevent regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Rule #2 (Documentation Driven Development) of the coding guidelines, the task is not complete until the documentation reflects the new code/architecture.
This PR introduces significant behavioral changes:
useDataScopenow returnsundefinedinstead of throwing when context is missingschema.dataorschema.props.dataThese changes should be documented in:
packages/react/README.mdor equivalent documentation for theuseDataScopehook behavior changecontent/docs/components/complex/table.mdxto show the inline data usage pattern for SSR scenariosThe documentation currently shows examples using only the
dataproperty directly on the schema, but doesn't explain the context-optional behavior or the fallback chain (boundData || schema.data || schema.props?.data).