Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minified React error #130 #533

Open
FacuCarbon opened this issue May 2, 2022 · 18 comments
Open

Minified React error #130 #533

FacuCarbon opened this issue May 2, 2022 · 18 comments

Comments

@FacuCarbon
Copy link

Hello! first to congratulate for the operation, it is exquisite.
On the other hand, locally it works perfectly for me. But when uploading it to production, I get the error: Uncaught Error: Minified React error #130 with the component, I use vite, do you have any solution? Thank you so much.

@nerijusgood
Copy link

nerijusgood commented May 10, 2022

Have the same minification issue. It's something with imports.

This package needs to update!

To recreate just use Vite build and this will try to minify and break

@rogorman9
Copy link

This needs a real fix for sure, but as a workaround I was able to get it to work by doing this:

import PI from "react-phone-input-2";
const ReactPhoneInput = PI.default ? PI.default : PI;

@FacuCarbon
Copy link
Author

@rogorman9
Thank you very much! this solution worked for me. Could you explain a little more why it happens?

@femi-Zedev
Copy link

femi-Zedev commented Jul 24, 2022

I'm using react-phone-input-2 too with vite and React Ts and stuck on the same issue. @rogorman9 workaround didn't work for me. The type checker says "Property 'default' does not exist on type 'FC' ". They should take a look at this issue

@femi-Zedev
Copy link

ReactPhoneInput

Finaly I managed to make it work. I convert my component to JSX to avoid type checking

@Thibaud05
Copy link

Dirty fix for TSX

const ReactPhoneInput = (PI as any).default !== null ? (PI as any).default : PI

@femi-Zedev
Copy link

So I come with a workound that works for both dev and prod. It's just litteraly checking environment mode. To do so you have to import React Phone Input like in previous workaround by @Thibaud05 and based on env mode apply the fix
import PI from "react-phone-input-2"; const ReactPhoneInput = import.meta.env.PROD ? (PI as any).default : PI;
Note that I use import.meta.env.PROD because of Vite. If you are using CRA consider using process.env.NODE_ENV === 'development' to check if your are in prod or dev

@TawalMc
Copy link

TawalMc commented Nov 14, 2022

@arnaudakotonou97 great

@Sashankr
Copy link

Sashankr commented Jan 4, 2023

This needs a real fix for sure, but as a workaround I was able to get it to work by doing this:

import PI from "react-phone-input-2";
const ReactPhoneInput = PI.default ? PI.default : PI;

Thank you very much! I am using React 18 , this works!

@zeyarpaing
Copy link

I published a package based on #532 changes because PR is still pending and my codebase need it urgently. You can just find and replace all the occurrences of react-phone-input-2 to vreact-phone-input.
vreact-phone-input

@ValterNeto9
Copy link

Dirty fix for TSX

const ReactPhoneInput = (PI as any).default !== null ? (PI as any).default : PI

It works for me! Thanks a lot!

@ValterNeto9
Copy link

Hello! first to congratulate for the operation, it is exquisite. On the other hand, locally it works perfectly for me. But when uploading it to production, I get the error: Uncaught Error: Minified React error #130 with the component, I use vite, do you have any solution? Thank you so much.

I faced the same problem! your thread save my life. Thanks man!

@JulesImbert
Copy link

thanks it work

@ahsan-khan1999
Copy link

@rogorman9 ;
Thanks man! this solution worked

@gamegee
Copy link

gamegee commented Apr 14, 2023

Hello, same issue here I will go with the workaround 👍
If you want to keep typesafety this solution works:

import React from 'react'
import PI, { PhoneInputProps } from 'react-phone-input-2'

const ReactPhoneInput: React.FC<PhoneInputProps> = (PI as any).default || PI

@bl00mber @rebebop do you plan a long term fix for this ?

@sample-usr
Copy link
Contributor

@gamegee I haven't updated that package in a long time. But I'll take a look at it over the weekend to see if I can add a quick fix to it.

@chaudharyShub
Copy link

chaudharyShub commented May 3, 2023

const ReactPhoneInput = (RPI as any).default ? (RPI as any).default : RPI;

If I am using this, I am not able to use countryCodeEditable={false} and country code is deleteable, and if I don't use the above code, my code is breaking in production server.

@FacuCarbon
Copy link
Author

FacuCarbon commented May 3, 2023

const ReactPhoneInput = (RPI as any).default ? (RPI as any).default : RPI;

Si estoy usando esto, no puedo usar countryCodeEditable={false} y el código de país se puede eliminar, y si no uso el código anterior, mi código se está rompiendo en el servidor de producción.

Me pasó lo mismo y lo solucioné creando un componente ts de esta manera:

import PI from "react-phone-input-2"; const ReactPhoneInput = import.meta.env.PROD ? (PI as any).default : PI; export default ReactPhoneInput;

y en la vista necesaria directamente lo importas y lo podes usar normalmente. Aclaro que lo metí en un componente ts, para poder reutilizarlo a lo largo de mi aplicación.

import ReactPhoneInput from "../phone/Phone";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests