Skip to content

Commit

Permalink
Check for schema and set default to {} in useDatastore (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgading authored Apr 22, 2024
1 parent f1ba888 commit cc38ef3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@civicactions/cmsds-open-data-components",
"version": "3.1.6",
"version": "3.1.7",
"description": "Components for the open data catalog frontend using CMS Design System",
"main": "dist/main.js",
"source": "src/index.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/services/useDatastore/useDatastore.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ const useDatastore = (
useEffect(() => {
if(data) {
const propertyKeys =
data.schema[id] && data.schema[id].fields
data.schema && data.schema[id] && data.schema[id].fields
? Object.keys(data.schema[id].fields)
: [];
setValues(data.results), setCount(data.count);
if (propertyKeys.length) {
setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
}
setSchema(data.schema);
if(data.schema) {
setSchema(data.schema);
}
}
}, [data])

Expand Down

0 comments on commit cc38ef3

Please sign in to comment.