Skip to content

Instantly share code, notes, and snippets.

@asiniy
Created July 4, 2018 12:36
Show Gist options
  • Save asiniy/23b3df32b190fe57dabdb354d7d07a33 to your computer and use it in GitHub Desktop.
Save asiniy/23b3df32b190fe57dabdb354d7d07a33 to your computer and use it in GitHub Desktop.
MyComponentFinal.jsx // Extending JavaScript with ease (beginner level tutorial)
import React from 'react'
import objectFetch from 'object-fetch'
INNER_CIRCLE_TARGETS_COUNT = 10
class MyComponent extends React.Component {
render() {
// A big function with a complex logic
const { collectorGroup } = this.props
// Line below will throw an error if there is no `targets_count` property in the dom.
const collectorGroupHasFewCircles = (objectFetch(collectorGroup, 'targets_count') > INNER_CIRCLE_TARGETS_COUNT)
// return big render here
}
}
export default MyComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment