React / Redux / Firebase延迟加载

时间:2019-02-08 09:37:43

标签: reactjs react-redux react-redux-firebase

import React, { Component } from 'react';
import Notifications from './Notifications';
import ProjectList from '../projects/ProjectList';
import { connect } from 'react-redux';
import { firebaseConnect } from 'react-redux-firebase';
import { compose } from 'redux';
import { Redirect } from 'react-router-dom';

class Dashboard extends Component {
  render() {
    const { posts, auth } = this.props;
    // if (!auth.uid) return <Redirect to="/signin" />;
    return (
      <div className="dashboard container">
        <div className="row">
          <div className="col s12 m6 ">
            <ProjectList posts={posts} />
          </div>
          <div className="col s12 m5 offset-m1">
            <Notifications />
          </div>
        </div>
      </div>
    );
  }
}

const mapStateToProps = state => {
  return {
    posts: state.firebase.ordered.Posts,
    auth: state.firebase.auth
  };
};


export default compose(
  connect(mapStateToProps),
  firebaseConnect([{ path: 'Posts' }])
)(Dashboard);

我使用react-redux-firebase firebaseConnect从firebase实时数据库加载帖子。

问题是当我要延迟加载(无限滚动)时,它一次加载所有帖子。

0 个答案:

没有答案