使用placeholder for react-native-picker

时间:2017-08-22 11:25:56

标签: javascript android react-native datepicker

我是反应原生的新手。请帮我解决这个问题。我一直试图在主页上显示react-native-picker(默认情况下没有任何用户操作)。我的代码

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import DatePicker from 'react-native-picker';
let data = [];
    for(var i=0;i<100;i++){
       data.push(i);
 }

并在组件类(渲染函数)中添加了datepicker,就像这样

<DatePicker pickerData={data} selectedValue= {59}    />

我收到错误

 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

请帮我解决这个问题。我试过

DatePicker.init({
    pickerData: data,
    selectedValue: [59],
    onPickerConfirm: data => {
        console.log(data);
    },
    onPickerCancel: data => {
        console.log(data);
    },
    onPickerSelect: data => {
        console.log(data);
    }
});
DatePicker.show();

那些都很好。但是我希望在主页上显示,而不需要任何操作。

0 个答案:

没有答案