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 committed Sep 19, 2018
1 parent 13e8eb3 commit df6c852
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 1 addition & 5 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions client/dist/js/vendor.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 df6c852

Please sign in to comment.