dorkyboi/react-native-calendar-timetable

Cant find variable React in Headers and Hours components

Closed this issue · 4 comments

Simulator_Screenshot_-iPhone_15_Pro_Max-_2024-03-18_at_13 26 01
Simulator_Screenshot_-iPhone_15_Pro_Max-_2024-03-18_at_13 25 47
Too many hours spent on this and still nothing.

I am using these versions:

 "react": "^18.0.0",
   "react-native": "0.69.5",
   "react-native-calendar-timetable": "^1.0.6",
   "@types/react": "^18.2.66",
   "@types/react-native": "^0.73.0",

I am importing it like this:

import Timetable from "react-native-calendar-timetable";

and using it like this:

 <Timetable
                items={postedJobs}
                />

If i keep it like this the app crashes with the error: Cant find variable React, which is directing me inside the library at the Headers and Hours components:

       Could not find a declaration file for module 'react-native'. '/node_modules/react-native/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native';`ts(7016)

Could not find a declaration file for module 'react-native'. '/node_modules/react-native/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native';`ts(7016)

Could not find a declaration file for module 'react-native'. '/node_modules/react-native/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native';`ts(7016)

I also am getting this warnings at the components but those are not the one crashing the app.

What i tried is deleting node_modules, package-lock.json, clean building, clear cache - I also tried to import React from "react" in the components where the error was supposed to be but that also did not fix it!

Okay so what I did is a nasty workaround but until it gets fixed is the only way.

You have to Import React from 'react' inside the library in components, helpers everywhere where the import is missing.

Happy coding guys :)

import React from "react"; statements are obsolete with the new JSX transform in React 17, and as such are not included in this library.
I shall release a new minor version to provide support for React <17.
Thank you

Fixed in v1.0.7