Failed prop type: Invalid prop?

Failed prop type: Invalid prop 'renderRow' of type 'function' supplied to 'Card', expected 'object'.
Failed prop type: Invalid prop 'dataArray' of type 'array' supplied to 'Card', expected 'object'.
import React, { Component } from 'react';
import {
    Text,
    AsyncStorage,
    TextInput
} from 'react-native';

import {
    Container,
    Card,
    CardItem,
    Header,
    Footer,
    Title,
    Button,
    Icon,
    Content,
    Body,
    List,
    Item,
    Input
} from 'native-base';

import * as firebase from 'firebase';

const firebaseConfig = {
    apiKey: "myKey",
    authDomain: "myApp.firebaseapp.com",
    databaseURL: "myApp.firebaseio.com",
    projectId: "myApp",
    storageBucket: "myApp.appspot.com",
    messagingSenderId: "384632182223"
  };
const firebaseApp = firebase.initializeApp(firebaseConfig);

export default class Pizza extends Component {
    constructor(props) {
        super(props);
        this.tasksRef = firebaseApp.database().ref();
        this.state = {
            user:null,
            loading: true,
            newTask: ""
        }
    }

    componentDidMount(){
        this.listenForTasks(this.tasksRef);
    }

    listenForTasks(tasksRef) {
        tasksRef.on('value', (dataSnapshot) => {
            var tasks = [];
            dataSnapshot.forEach((child) => {
                tasks.push({
                    name: child.val().name,
                    _key: child.key
                });
            });

            this.setState({
                tasks:tasks
            });
        });
    }

    _renderItem(task) {
        return (
            <CardItem>
                <Text>{task.name}</Text>
            </CardItem>
        );
    }

    _addTask() {
        if (this.state.newTask === "") {
            return;
        }
        this.tasksRef.push({ name: this.state.newTask });
        this.setState({newTask: ""});
    }

    render() {
        return(
            <Container>
                <Header style={{backgroundColor: '#665CAC'}} >
                    <Body>
                        <Title style={{ color: '#fff' }}>My Todos</Title>
                    </Body>
                </Header>
                <Content >
                    <Item>
                        <Icon name='ios-create-outline' />
                        <Input 
                            value={this.state.newTask}
                            placeholder='New task...'
                            onChangeText={(text) => this.setState({newTask: text})}
                        />
                        <Button onPress={this._addTask.bind(this)} >
                            <Icon name='ios-add' />
                        </Button>
                    </Item>
                    
                    <Card 
                        dataArray={this.state.tasks}
                        renderRow={this._renderItem.bind(this)} 
                    >
                    </Card>
                </Content>
            </Container>
        );
    }

}
  • Вопрос задан
  • 881 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы