 ContextTypes =
   loadQueue: (props, propName, componentName) ->
     loadQueue = props[propName]
-    unless loadQueue?
-      console.warn "Required context `#{propName}` was not specified for `#{componentName}`"
-      return false
-    unless typeof loadQueue['enqueue'] is 'function'
+    if loadQueue? and typeof loadQueue['enqueue'] isnt 'function'
       console.warn "Context `#{propName}` must have an `enqueue` method for `#{componentName}`"
       return false
     true

  displayName: 'ImageLoader'
  mixins: [LoaderMixin]
  propTypes:
    preloader: PropTypes.func
    onLoad: PropTypes.func
    onError: PropTypes.func
  getDefaultProps: -> preloader: img, loader: imageLoader
  handleLoad: (el) -> @setState status: Status.LOADED
  handleError: (error) -> @setState {error, status: Status.FAILED}
  render: ->
    switch @state.status
      when ImageLoader.Status.PENDING, ImageLoader.Status.LOADING
        @props.preloader()
      when ImageLoader.Status.ERROR
        (div className: 'error', @props.children)
      when ImageLoader.Status.LOADED
        (img
          src: @props.src
          onLoad: @props.onLoad
          onError: @props.onError
        )

    status: Status.PENDING
  componentDidMount: ->
    return unless @state.status is Status.PENDING
    if @context?.loadQueue?
      loader = (callback) =>
        @loadImage @props.src, callback
      loadResult = @context.loadQueue
        .enqueue loader, priority: @props.priority
      @setState {loadResult}
    else
      @loadImage @props.src
  componentWillReceiveProps: (nextProps) ->
    if nextProps.priority? and @state?.loadResult?
      @state.loadResult.priority nextProps.priority
