Skip to content

Commit

Permalink
fix: runtime errors on slideform
Browse files Browse the repository at this point in the history
_uid and item were undefined and throwing errors on navigation past the last form to the next interface. this fix uses optional chaining to set id and intiialValues to undefined instead of throwing error
  • Loading branch information
buckhalt committed Jan 29, 2024
1 parent 0ac9615 commit 8669a75
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/interviewer/containers/SlidesForm/SlideFormNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { withProps } from 'recompose';
import Scroller from '~/lib/ui/components/Scroller';
import { entityAttributesProperty, entityPrimaryKeyProperty } from '@codaco/shared-consts';
import {
entityAttributesProperty,
entityPrimaryKeyProperty,
} from '@codaco/shared-consts';
import Node from '../../components/Node';
import Form from '../Form';

Expand All @@ -11,15 +14,17 @@ class SlideFormNode extends PureComponent {
const { id, item, onUpdate } = this.props;
// TODO: is item (node) neccessary?
onUpdate?.(id, item, formData);
}
};

render() {
const {
form = {},
item,
initialValues,
subject,
submitButton = <button type="submit" key="submit" aria-label="Submit" hidden />,
submitButton = (
<button type="submit" key="submit" aria-label="Submit" hidden />
),
id,
otherNetworkEntities,
onScroll,
Expand Down Expand Up @@ -60,8 +65,8 @@ SlideFormNode.propTypes = {
};

const withNodeProps = withProps(({ item }) => ({
id: item[entityPrimaryKeyProperty],
initialValues: item[entityAttributesProperty],
id: item?.[entityPrimaryKeyProperty],
initialValues: item?.[entityAttributesProperty],
}));

const EnhancedSlideFormNode = withNodeProps(SlideFormNode);
Expand Down

0 comments on commit 8669a75

Please sign in to comment.