Skip to content

Instantly share code, notes, and snippets.

@alieslamifard
Last active February 28, 2019 12:57
Show Gist options
  • Save alieslamifard/8331ecedcce17709b32aab5d11124484 to your computer and use it in GitHub Desktop.
Save alieslamifard/8331ecedcce17709b32aab5d11124484 to your computer and use it in GitHub Desktop.
code-sample-schema-validation-1
const foo = { bar: [ { hey : "you" } ] };
if ( foo && foo.bar && foo.bar.length ) {
return foo.bar.map( items => <Component data={items.hey} /> );
}
if ( foo?.bar?.length ) {
return foo.bar.map(items => <Component data={items.hey} />)
}
export function async someAction() {
const response = await someHelperFunctionThatCallAnotherService();
if (!response) {
return dispatch({
type: 'FAILURE'
})
}
return dispatch({
type: 'SUCCESS',
data: response
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment