Skip to content

Instantly share code, notes, and snippets.

@bkeating bkeating/merge.js
Created Sep 1, 2017

What would you like to do?
// This works... (returns a merged object)
const combinedFormSchema = this.state.session && _.merge(
// This does not (returns an array of objects, not a merged object)
const combinedFormSchema = this.state.session && _.merge(, building => building.schema)

This comment has been minimized.

Copy link
Owner Author

commented Sep 1, 2017

It's because the approach above is only citing 1 argument. By spreading the mapped results out, we give merge the right argument shape:

const buildingUiSchemas = this.state.session &&
  this.state.session.building_list, building => building.uischema
const combinedFormUiSchema = this.state.session && _.merge(...buildingUiSchemas);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.