简体   繁体   English

在使用react-date-range的Calendar组件时如何解决错误

[英]How to fix error when working with Calendar Component of react-date-range

I am working with Calendar component of react-date-range but I have seen following error. 我正在使用react-date-range的 Calendar组件,但是看到以下错误。 在此处输入图片说明

This is simple code I using. 这是我使用的简单代码。

    import React, { Component } from 'react';
    import { Platform, StyleSheet, Text, View } from 'react-native';
    import { Calendar } from 'react-date-range';

    export default class App extends Component {
      handeeSelect(date) {
        console.log(date);
      }
      render() {
        return (
          <View>
            <Calendar
              onInit={this.handeeSelect}
              onChange={this.handeeSelect}
            />
          </View>
        );
      }
    }

How to fix it? 如何解决?

Edit: As mentioned in the comments, the issue revolved around the library in use. 编辑:如评论中所述,问题围绕使用中的库。 Either the linking to the Native code or the library was causing compatibility issues. 链接到本机代码或库导致兼容性问题。 Be sure to link libraries you add to native code when adding new ones. 添加新库时,请确保链接添加到本机代码的库。

I think you need to wrap the calendar component in a div because React-Native View is weird and needs a child element. 我认为您需要将日历组件包装在div因为React-Native View很奇怪,并且需要一个子元素。

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import { Calendar } from 'react-date-range';



   export default class App extends Component {
  handeeSelect(date) {
    console.log(date);
  }

  render() {
    return (
      <View>
        <div>
          <Calendar onInit={this.handeeSelect} onChange={this.handeeSelect} />
        </div>
      </View>
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用webpack模块捆绑器实现react-date-range picker? - How to implement react-date-range picker with webpack module bundler? 如何在 react-date-range 中的日期范围 select 之后自动关闭日期范围模式 - How to auto close date range modal after date range select in react-date-range NPM 在 react-date-range 包中找不到模块“date-fns/local/en-US” - NPM cannot find module 'date-fns/local/en-US' in react-date-range package 如何在不更改 ja 语言环境中的工作日名称格式的情况下修复 react-calendar 中的日期格式? - How to fix date format in react-calendar without changing weekday name format in ja locale? React Native:如何在onPress期间修复Button组件的错误? - React Native: How to fix error with Button component during onPress? 当 React JS 分页组件在点击时什么都不做时如何修复? - How to fix when React JS Pagination component does Nothing on Click? 日期范围选择器组件在模式内不起作用 - Date Range Picker component not working inside a modal 使用递归和数组时如何修复错误? - How to fix the error when working with recursion and array? 在 ReactJS 中更改组件时如何修复错误覆盖 CSS - How to fix error override CSS when change component in ReactJS 如何修复 daterangepicker 中的自定义日期范围问题? - How to fix custom date range issue in daterangepicker?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM