Skip to content

Instantly share code, notes, and snippets.

@firec0der
Created November 2, 2016 02:51
Show Gist options
  • Save firec0der/6f7ef87eba01544d76b9ce9043953bfe to your computer and use it in GitHub Desktop.
Save firec0der/6f7ef87eba01544d76b9ce9043953bfe to your computer and use it in GitHub Desktop.
onSearchSuccess = (places) => {
const changeHeader = (num, callback) => {
const header = { formHeader: `We Found ${num} Local Caregivers` };
this.setState(
...(callback ? [header, callback] : [header])
);
};
Array.isArray(places) && (
places.reduceRight((acc, place, index) =>
changeHeader.bind(null, index, () => setTimeout(acc, 25)),
changeHeader.bind(null, places.length)
)
)();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment