       'add' # add class if shouldPinHeader is true
     ]
 
-    shouldPinHeader = @shouldPinHeader(@state.scrollTop) * 1
+    @setState(pinned : @shouldPinHeader(prevState.scrollTop, @state.scrollTop))
+    shouldPinHeader = @state.pinned * 1
     classAction = addOrRemove[shouldPinHeader]
     document.body.classList[classAction]('pinned-on')
 

  componentWillUnmount: ->
    document.body.classList.remove(@documentBodyClass)

  shouldPinHeader: (scrollTop) ->
    scrollTop > @props.buffer

  shouldComponentUpdate: (nextProps, nextState) ->
    # ignore scrolling state changes when checking should component update

    nextStateNoScroll = _.omit(nextState, 'isScrolling', 'scrollTop')

    # manually check if should pin has changed
    didShouldPinChange = not @state.pinned is @shouldPinHeader(@state.scrollTop, nextState.scrollTop)
    # check props and non-scroll states
    didPropsUpdate = not _.isEqual(@props, nextProps)
    didStateUpdate = not _.isEqual(stateNoScroll, nextStateNoScroll)
