Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to use react-native-calendars

error: bundling failed: Error: Unable to resolve module hoist-non-react-statics from E:\DEVELOPMENTWORKSPACE\test\node_modules\react-native-calendars\src\expandableCalendar\asCalendarConsumer.js: Module hoist-non-react-statics does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968

To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.
like image 557
Ramana Sakhavarapu Avatar asked Aug 19 '19 10:08

Ramana Sakhavarapu


People also ask

How do I use Calendar in react-native?

import { Calendar, CalendarList, Agenda } from 'react-native-calendars'; All parameters for components are optional. By default the month of current local date will be displayed. Parameters that require date types accept YYYY-MM-DD formatted date-strings , JavaScript date objects, calendar objects and UTC timestamps .

How do I open calender in react-native?

import React, { Component } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import CalendarPicker from 'react-native-calendar-picker'; export default class App extends Component { constructor(props) { super(props); this. state = { selectedStartDate: null, selectedEndDate: null, }; this.


1 Answers

The problem is that src/expandableCalendar/asCalendarConsumer.js is trying to import 'hoist-non-react-statics' which is not declared as a dependency in package.json So the solution is to add it in package.json as this:

"dependencies": {
"lodash": "^4.0.0",
"prop-types": "^15.5.10",
"xdate": "^0.8.0",
"hoist-non-react-statics": "*"},

than run npm install run react-native run-ios and you're up to go!

like image 58
Emanuele Sacco Avatar answered Nov 14 '22 04:11

Emanuele Sacco