const debounce = require('lodash.debounce'); const ReactRedux = require('react-redux'); const Infinite = require('react-infinite'); const actions = require('./actions'); const React = require('react'); const { connect } = ReactRedux; const { fetch, filter } = actions; const mapStateToProps = (state) => { return state; }; const mapDispatchToProps = (dispatch, ownProps) => { return { fetch: () => { return dispatch(fetch()); }, filter: (payload) => { return dispatch(filter(payload)); } } }; const List = ({ items = [], filtered, input = '', fetching = false, fetch, filter }) => { const _items = (filtered || items).map((item) => { return (
{item.title}
); }); const _loading = (
Loading...
); const _filter = debounce(filter, 100); const onChange = (ev) => _filter(ev.target.value); return (
{_items}
); }; module.exports = connect( mapStateToProps, mapDispatchToProps, )(List);