Skip to content

Commit

Permalink
Making reloading schema on FormBuilderLoader mount optional rather th…
Browse files Browse the repository at this point in the history
…an always off
  • Loading branch information
ScopeyNZ authored and robbieaverill committed Sep 20, 2018
1 parent d9a6c10 commit e3f0bd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion client/src/containers/FormBuilderLoader/FormBuilderLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class FormBuilderLoader extends Component {
}

componentDidMount() {
if (!this.props.schema) {
const { schema, refetchSchemaOnMount } = this.props;

if (refetchSchemaOnMount || !schema) {
this.fetch();
}
}
Expand Down Expand Up @@ -432,12 +434,17 @@ FormBuilderLoader.propTypes = Object.assign({}, basePropTypes, {
identifier: PropTypes.string.isRequired,
schemaUrl: PropTypes.string.isRequired,
schema: schemaPropType,
refetchSchemaOnMount: PropTypes.bool.isRequired,
form: PropTypes.string,
submitting: PropTypes.bool,
onFetchingSchema: PropTypes.func,
loadingComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
});

FormBuilderLoader.defaultProps = {
refetchSchemaOnMount: true,
};

function mapStateToProps(state, ownProps) {
const schema = state.form.formSchemas[ownProps.schemaUrl];
const identifier = createFormIdentifierFromProps({ ...ownProps, schema });
Expand Down

0 comments on commit e3f0bd3

Please sign in to comment.