Skip to content

Commit

Permalink
fix(react): refactoring hasKeySchema computation (datahub-project#3146)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored and shirshanka committed Aug 27, 2021
1 parent 70c92db commit 6319228
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ export default function SchemaView({
fetchPolicy: 'no-cache',
});

const hasKeySchema = useMemo(
() => (schema?.fields?.findIndex((field) => field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1) || -1) !== -1,
[schema],
);
const hasKeySchema = useMemo(() => {
const keySchemaIndex = schema?.fields?.findIndex((field) => field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1);
if (keySchemaIndex !== undefined && keySchemaIndex > -1) {
// We found a key schema.
return true;
}
return false;
}, [schema]);

const [showKeySchema, setShowKeySchema] = useState(false);

Expand Down

0 comments on commit 6319228

Please sign in to comment.