Having struggled with this issue for a while now without any success, I have searched through numerous questions here but none seem to address my specific case. Therefore, I kindly request your assistance.
I am encountering difficulties passing props through the <WeatherCard/>
component. In the test application, there are 2 tabs, and both tabs render the <WeatherCard/>
. When I hover over <WeatherCard/>
in Tab1.tsx, TypeScript displays the wrong (unexpected) props (WeatherProps), as shown below:
(alias) const WeatherCard: React.FC<WeatherProps>
import WeatherCard
Conversely, when I hover over <WeatherCard/>
in Tab2.tsx, it correctly shows the props being passed, as seen below:
(alias) const WeatherCard: React.FC<WeatherCardProps>
import WeatherCard
Additionally, an error is displayed as follows:
[react-scripts] TS2322: Type '{ weatherIconUrl: string; weatherData: any; weatherVars: string[]; }' is not assignable to type 'IntrinsicAttributes & WeatherProps & { children?: ReactNode; }'. [react-scripts] Property 'weatherIconUrl' does not exist on type 'IntrinsicAttributes & WeatherProps & { children?: ReactNode; }'.
After logging the props passed in <WeatherProperty/>
, it appears that these props are indeed the ones being passed to <WeatherCard/>
. It seems like, for some reason, the props declared in <WeatherProperty/>
are not being recognized when used in Tab1.
Below is the code snippet:
Tab1.tsx
// Code for Tab1...
Tab2.tsx
// Code for Tab2...
WeatherCard.tsx
// Code for WeatherCard...
WeatherProperty.tsx
// Code for WeatherProperty...