Closed biancakleynhans closed 1 year ago
@biancakleynhans you have multiple versions of @types/react component. This is common issue.
If you use yarn, it is easy to fix, you just have to add "resolutions": {} field into your package.json, and specify exact version of conflicting package. This is the solution for multiple problems, also can reduce bundle size if you define any package which is duplicated in your bundle.
"resolutions": {
"core-js": "3.32.0",
"@babel/core": "7.22.9",
"@babel/preset-react": "7.22.5",
"@types/node": "20.4.5",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
"@typescript-eslint/parser": "6.2.1",
"@typescript-eslint/eslint-plugin": "6.2.1",
"typescript": "5.1.6"
}
This is a set of commonly duplicated packages in my projects. use with caution. you should define your own compatible versions. Here is the latest current at the moment 1 Aug 2023. updating almost every day. In case you are updating versions, use yarn outdated
. You have to update both, dependencies/devDependencies and resolutions.
In case of npm, npm is buggy, and instead of resolutions, it uses overrides keyword. I had no success with npm, so you are on your own here.
Caused by @types/react - 18.2.23, lowering the version fixes it for now, but there should be a fix.
any solution for this?, I have the same issue!
@ELHart05 @ivosabev it is a common issue, just enfoece the latest version in your package.json for @types/react, @types @node, etc. you can see all duplicates which can cause this issue in your lock file.
I've explained the fix above.
@biancakleynhans you have multiple versions of @types/react component. This is common issue.
If you use yarn, it is easy to fix, you just have to add "resolutions": {} field into your package.json, and specify exact version of conflicting package. This is the solution for multiple problems, also can reduce bundle size if you define any package which is duplicated in your bundle.
"resolutions": { "core-js": "3.32.0", "@babel/core": "7.22.9", "@babel/preset-react": "7.22.5", "@types/node": "20.4.5", "@types/react": "18.2.18", "@types/react-dom": "18.2.7", "@typescript-eslint/parser": "6.2.1", "@typescript-eslint/eslint-plugin": "6.2.1", "typescript": "5.1.6" }
This is a set of commonly duplicated packages in my projects. use with caution. you should define your own compatible versions. Here is the latest current at the moment 1 Aug 2023. updating almost every day. In case you are updating versions, use
yarn outdated
. You have to update both, dependencies/devDependencies and resolutions.In case of npm, npm is buggy, and instead of resolutions, it uses overrides keyword. I had no success with npm, so you are on your own here.
This is the only correct solution! closing an issue to reduce spam
Type error: 'GoogleMap' cannot be used as a JSX component.
Explanation of the issue:
Deploying to vercel keeps breaking due to Type error: 'GoogleMap' cannot be used as a JSX component. when using GoogleMap component from "@react-google-maps/api". But works perfectly in localhost as well as locally building the the project
Environment:
"next": "13.4.9", "react": "18.2.0", "@react-google-maps/api": "^2.19.2" ==> ALL VERSIONS FROM 2.10.2 GIVES THIS EXCACT ERROR WHEN USING WITH NEXT JS 13
os: windows node --18
How does it behave?
Locally it is working, local build working failing when deploying to vercel
How should it behave correctly?
Build needs to work on vercel
Incorrect:
Code
'use client';
import React, {useState, useEffect, useMemo} from 'react'; import {GoogleMap, MarkerF, useGoogleMap, useLoadScript} from '@react-google-maps/api'; import {providerJourneyType, useCoverage} from '@/context/CoverageContext';
export default function CoverageMap() { const {handleSetMap, getAddressObj, providerType, mapSource} = useCoverage();
}