// @flow
import React from 'react'

module.exports = (options: any) =>
  React.createClass({
    displayName: 'GoogleFont',

    render () {
      // Create family + styles string
      let fontsStr = ''
      if (options.googleFonts) {
        const fonts = options.googleFonts.map((font) => {
          let str = ''
          str += font.name.split(' ').join('+')
          str += ':'
          str += font.styles.join(',')

          return str
        })

        fontsStr = fonts.join('|')

        if (fontsStr) {
          return React.DOM.link({
            href: `//fonts.googleapis.com/css?family=${fontsStr}`,
            rel: 'stylesheet',
            type: 'text/css',
          })
        } else {
          return null
        }
      } else {
        return null
      }
    },
  })


// @flow
import React from 'react'

module.exports = (options: any) =>
  React.createClass({
    displayName: 'GoogleFont',

    render () {
      // Create family + styles string
      let fontsStr = ''
      const fonts = options.googleFonts.map((font) => {
        let str = ''
        str += font.name.split(' ').join('+')
        str += ':'
        str += font.styles.join(',')

        return str
      })

      fontsStr = fonts.join('|')

      if (fontsStr) {
        return React.DOM.link({
          href: `//fonts.googleapis.com/css?family=${fontsStr}`,
          rel: 'stylesheet',
          type: 'text/css',
        })
      } else {
        return null
      }
    },
  })


--- 
+++ 
@@ -8,23 +8,27 @@
     render () {
       // Create family + styles string
       let fontsStr = ''
-      const fonts = options.googleFonts.map((font) => {
-        let str = ''
-        str += font.name.split(' ').join('+')
-        str += ':'
-        str += font.styles.join(',')
+      if (options.googleFonts) {
+        const fonts = options.googleFonts.map((font) => {
+          let str = ''
+          str += font.name.split(' ').join('+')
+          str += ':'
+          str += font.styles.join(',')
 
-        return str
-      })
+          return str
+        })
 
-      fontsStr = fonts.join('|')
+        fontsStr = fonts.join('|')
 
-      if (fontsStr) {
-        return React.DOM.link({
-          href: `//fonts.googleapis.com/css?family=${fontsStr}`,
-          rel: 'stylesheet',
-          type: 'text/css',
-        })
+        if (fontsStr) {
+          return React.DOM.link({
+            href: `//fonts.googleapis.com/css?family=${fontsStr}`,
+            rel: 'stylesheet',
+            type: 'text/css',
+          })
+        } else {
+          return null
+        }
       } else {
         return null
       }
Check that options declares Google Fonts before building component
