Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import _ from 'lodash';
- import React, { Component } from 'react';
- import { connect } from 'react-redux';
- import { FlatList } from 'react-native';
- import { employeesFetch } from '../actions';
- import ListItem from './ListItem'
- class EmployeeList extends Component {
- componentWillMount() {
- this.props.employeesFetch();
- }
- renderItem(employee) {
- return <ListItem employee={employee} />;
- }
- render() {
- return (
- <FlatList
- data={this.props.employees}
- renderItem={this.renderItem.bind(this)}
- keyExtractor={(employee, index) => index.toString()}
- />
- );
- }
- }
- const mapStateToProps = (state) => {
- const employees = _.map(state.employees, (val, uid) => {
- return { ...val, uid };
- });
- return { employees }
- };
- export default connect(mapStateToProps, { employeesFetch })(EmployeeList);
Advertisement
Add Comment
Please, Sign In to add comment