| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import _ from 'lodash';
- import React, { Component } from 'react';
- import { Text, ListView } from 'react-native';
- import { connect } from 'react-redux';
- import { cursadasFetch } from '../actions/';
- import ItemCursada from './ItemCursada';
- class ListaCursadas extends Component {
- componentWillMount() {
- this.props.cursadasFetch();
- this.createDataSource(this.props);
- }
- componentWillReceiveProps(nextProps) {
- this.createDataSource(nextProps);
- }
- createDataSource({cursadas,cursos}){
- //const {cursadas, cursos} = cursada;
- const ds = new ListView.DataSource({
- rowHasChanged: (r1,r2) => r1 !== r2
- });
- this.dataSource = ds.cloneWithRows(cursadas);
- }
- renderRow(data) {
- return <ItemCursada data={data}/>;
- }
- render() {
- return (
- <ListView
- enableEmptySections
- dataSource={this.dataSource}
- renderRow={this.renderRow} />
- );
- }
- };
- const mapStateToProps = state => {
- /*const cursadas = _.map(state.cursadas, (val, uid) => {
- return { ...val, uid };
- });*/
- return { cursadas: state.cursadasR.cursadas, cursos: state.cursadasR.cursos };
- };
- export default connect(mapStateToProps, { cursadasFetch })(ListaCursadas);
|