可能未处理的承诺拒绝(id:0):未定义不是对象

Possible Unhandled Promise Rejection (id:0): undefined is not an object

我有带有 Redux 的 React Native 应用程序,我正在尝试在组件的构造函数中从 Redux 获取数据。 我收到这样的错误: 可能未处理的承诺拒绝(id:0):未定义不是对象(评估'library.activeSections')

这是我的代码:

class Accordion extends Component {
...

constructor (props) {
super(props)
this.state = {
  activeSections: [this.props.initiallyActiveSection]
}

// if activeSection not specified, default to initiallyActiveSection
let { library } = this.props  
if (library.activeSections) {  //<-- here is an error library is undefined
  this.setState({activeSections: library.activeSections})
}

 _toggleSection (section) {
const activeSection = section
    let isOpened = this.state.activeSections.indexOf(section) >= 0 ? true : false
    var indexInActiveSections = this.state.activeSections.indexOf(section)
if (isOpened === true) {
      this.state.activeSections.splice(indexInActiveSections, 1)
    } else {
      this.state.activeSections.push(section)
    }

    this.props.libraryActions.setActiveSections(this.state.activeSections)

    this.setState({ activeSection })
    }

    render () {
...
}

}

    Accordion.PropTypes = {
  library: React.PropTypes.arrayOf(React.PropTypes.number)
}

export default connect(state => ({
    library: state.library
  }),
  (dispatch) => ({
    libraryActions: bindActionCreators(libraryActions, dispatch)
  })
)(Accordion)

module.exports = Accordion

这里是 library reducer reducers/library.js:

    import { Map } from 'immutable'

const initialState = Map({
  activeSections: [0]
})

export default function library (state = initialState, action = {}) {
  switch (action.type) {
    case 'SET_ACTIVE_SECTIONS':
      return {
        ...state,
        activeSections: action.activeSections
      }
    default:
      return state
  }
}

这是库操作 actions/library.js:

    export const setActiveSections = (activeSections) => {
  return {
    type: 'SET_ACTIVE_SECTIONS',
    activeSections
  }
}

这里是 reducers/index.js:

 import articles from './articles'
import journal from './journal'
import library from './library'

export {
  articles,
  journal,
  library
}

我无法理解为什么this.props

中没有库对象

希望得到您的帮助。

删除行module.exports = Accordion