Skip to content

Commit 8b5e099

Browse files
Copilothotlong
andcommitted
Address code review feedback: add guards for undefined values
- Add guard in useDataScope to return early if dataSource is undefined - Add validation in table renderer to handle missing accessor properties - Ensure empty string is displayed instead of undefined values Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 8a395ad commit 8b5e099

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/components/src/renderers/data-display/table.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ export const SimpleTableRenderer = ({ schema, className }: any) => {
5656
displayData.map((row: any, i: number) => (
5757
<TableRow key={row.id || i}>
5858
{columns.map((col: any, index: number) => {
59-
const accessor = col.key || col.accessorKey;
59+
const accessor = col.key || col.accessorKey || '';
60+
const value = accessor ? row[accessor] : '';
6061
return (
6162
<TableCell key={col.key || col.accessorKey || index}>
62-
{row[accessor]}
63+
{value}
6364
</TableCell>
6465
);
6566
})}

packages/react/src/context/SchemaRendererContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const useSchemaContext = () => {
3737
export const useDataScope = (path?: string) => {
3838
const context = useContext(SchemaRendererContext);
3939
const dataSource = context?.dataSource;
40-
if (!path) return dataSource;
40+
if (!dataSource || !path) return dataSource;
4141
// Simple path resolution for now. In real app might be more complex
4242
return path.split('.').reduce((acc, part) => acc && acc[part], dataSource);
4343
}

0 commit comments

Comments
 (0)