       @renderRejected @state.error
 
     else
-      # Until the initial promise is resolved or rejected, show the given children.
-      @props.children ? null
+      try
+        initialRender = if typeof @props.children is 'function'
+          @props.children()
+        else
+          @props.children
+        initialRender ? null
+      catch error
+        @renderRejected error
 
   componentDidUpdate: (prevProps, prevState) ->
     classList = @getDOMNode()?.classList

      classList?.remove @props.pendingClass

  renderResolved: (value) ->
    if typeof @props.then is 'string'
      @renderSimpleLookup value, @props.then.split '.'
    else
      @props.then.call this, value

  renderSimpleLookup: (value, path) ->
    until path.length is 0

  displayName: 'PromiseRenderer'

  getDefaultProps: ->
    promise: null
    pendingClass: 'promise-pending'
    tag: 'div'
    then: @::defaultThen
    catch: @::defaultCatch

