我有分量,這需要渲染之前獲取服務器數據:關於空支柱的警告:爲什麼會發生?
class BooksManage extends Component {
componentWillMount() {
const { dispatch, fetchManagePage } = this.props
dispatch(fetchManagePage())
}
render() {
const sections = this.props.books.map((section, index) => {
return (
<div className='row' key={index}>
<BookSectionContainer index={index} />
</div>
)
})
return (
<div className='row'>
<div className='col-md-8'>
{sections}
<BookPaginationContainer paginationClass='books' />
</div>
<div className='col-md-3'>
<div style={{position: 'fixed', width: 'inherit'}}>
<EmployeesListContainer />
</div>
</div>
</div>)
}
}
正如你所看到的,它使用BookPaginationContainer
,其預計幾個狀態參數:
Warning: Failed prop type: The prop `currentPage` is marked as required in `Paginate`, but its value is `undefined`.
等等
問題:由於BookPaginationContainer
是BooksManage
的孩子,我期望通過componentWillMount()
實現的是分派動作獲取需要的狀態參數。
實際發生的:
action REQUEST_MANAGE_PAGE @ 18:41:49.770
Warning: Failed prop type: The prop `currentPage` is marked as required in `Paginate`, but its value is `undefined`.
action RECEIVE_MANAGE_PAGE @ 19:01:40.327
所有頁面後呈現正確,但我關心的是如何好這一點。
「Paginate」組件在哪裏。 –