unform icon indicating copy to clipboard operation
unform copied to clipboard

Error using Form from @unform/mobile

Open MullerEsposito opened this issue 4 years ago • 40 comments

Description of bug

So, when I use the Form component from the @unform library, the metro bundle accuses the following error: _

"[Error: undefined Unable to resolve module react/jsx-runtime from node_modules/@unform/mobile/dist/index.js: react/jsx-runtime could not be found within the project."

_

To Reproduce

  1. Install the @unform/mobile dependency: yarn add @unform/mobile
  2. Import on React page the Form component: import { Form } from "@unform/mobile"
  3. Call the Form component in some form: <Form onSubmit={anyFunction}> <Input /> <Button>Enviar</Button> </Form>
  4. Build the App

Expected behavior

The App to be builded without errors.

Exception or Error


[Error: undefined Unable to resolve module `react/jsx-runtime` from `node_modules/@unform/mobile/dist/index.js`: react/jsx-runtime could not be found within the project.

Screenshots

Screenshot from 2021-01-30 03-19-36

Environment:

OS: Ubuntu React 16.13.1 React Native 0.63.4 @unform/mobile 2.1.4

Additional context

The repository can be cloned on follow address: https://github.com/MullerEsposito/gobarber/tree/mobile

MullerEsposito avatar Jan 30 '21 06:01 MullerEsposito

Tive o mesmo problema, atualizei o react para versão 17.0.1 e o react-dom também para a versão 17.0.1 e o problema acabou.

fermaiasoares avatar Jan 30 '21 19:01 fermaiasoares

@fermaiasoares Quando eu utilizo essa versão do React com Expo fica dando erro de 'Invalid hook call'... Parece que essa versão é incompatível com o Expo.

andredezzy avatar Jan 31 '21 00:01 andredezzy

Use a versão ^2.1.3 ao invés da ^2.1.4 e atualize o react para a v17.

Jonathansoufer avatar Jan 31 '21 16:01 Jonathansoufer

@Jonathansoufer também deu o mesmo erro com o Expo... Mas consegui uma solução: Unform versão 1.9.8 e o React na versão que o próprio Expo me entrega, no caso, a versão 16.13.1.

andredezzy avatar Jan 31 '21 19:01 andredezzy

Tive o mesmo problema, segue versões:

"react": "16.13.1", "react-native": "0.63.4", "@unform/core": "^2.1.3", "@unform/mobile": "^2.1.3",

patricpfranca avatar Feb 01 '21 17:02 patricpfranca

Tive o mesmo problema, estava passando meu projeto de JS para TS, resolvi usar o unform e apareceu o erro:

react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 @unform/core": 2.1.4 @unform/mobile": 2.1.4

funcionou a resposta do Jonathansoufer

lccoronel avatar Feb 02 '21 01:02 lccoronel

Tive esse problema esses dias e resolvi trocando para as versões: react: 17.0.1 react-dom: 17.0.1 @unform/core: 2.1.3 @unform/mobile: 2.1.3

Espero que funcione pra ti.

gbfonseca avatar Feb 02 '21 14:02 gbfonseca

Guys, just giving feedback. I don't know if here on Github there is a field to put a solution in Issues. I did what @fermaiasoares suggested and it was enough.

Pessoal, só dando o feedback. Não sei se aqui no Github tem algum campo pra colocar solução nas Issues. Eu fiz o que o @fermaiasoares sugeriu e foi suficiente.

Tive o mesmo problema, atualizei o react para versão 17.0.1 e o react-dom também para a versão 17.0.1 e o problema acabou.

MullerEsposito avatar Feb 02 '21 22:02 MullerEsposito

Enviroment: OS: Ubuntu 18.04 LTS react: 16.13.1, react-native: 0.63.4, @unform/core: 2.1.5, @unform/mobile: 2.1.5,

Same issue here. I did the same thing, changed version of react / react-dom to 17.0.1 and @unform/core - @unform/mobile to 2.1.3 and didn't work. So I try with react / react-dom 17.0.1 and @unform/core - @unform/mobile 2.1.5 and worked.

Tive o mesmo problema, troquei as versões react / react-dom pra 17.0.1 e @unform/core - @unform/mobile para 2.1.3 e não funcionou. Tentei com o react / react-dom 17.0.1 e @unform/core - @unform/mobile 2.1.5 e funcionou.

carlos-eugenio avatar Feb 03 '21 02:02 carlos-eugenio

Tive o mesmo problema aqui no react native. Resolvi conforme as respostas acima.

alanmatiasdev avatar Feb 03 '21 05:02 alanmatiasdev

@carlos-eugenio @bralandealmeida como ficou a versão de vocês do RN - React e @unform/mobile e /core ? to passando pelo msm problema...

jjairojr avatar Feb 05 '21 11:02 jjairojr

@carlos-eugenio @bralandealmeida como ficou a versão de vocês do RN - React e @unform/mobile e /core ? to passando pelo msm problema...

O que fiz foi baixar a versão pra 2.1.0 do unform e funcionou tranquilo... essa nova versão pede o React na versão 17 e ainda está em RC, portanto não mudei no React Native.

patricpfranca avatar Feb 05 '21 12:02 patricpfranca

@jjairojr estou usando o "react": "17.0.1". Uma alternativa pode ser a do @patricpfranca. Não cheguei a testar essa. Baixei a versão 2.3 do unform e também não rolou, então atualizei o react.

alanmatiasdev avatar Feb 05 '21 12:02 alanmatiasdev

@carlos-eugenio @bralandealmeida como ficou a versão de vocês do RN - React e @unform/mobile e /core ? to passando pelo msm problema...

Eu atualizei o react pra versão 17.0.1 e o unform pro 2.1.5 e resolveu.

carlos-eugenio avatar Feb 08 '21 22:02 carlos-eugenio

Guys don't want to sound rude, but English would be very much appreciated. Having to deal with issues is not fun, having to copy/paste entire thread to Google Translate is even less fun 🙂

For future english-speaking visitors of this issue; I can confirm that (at least as long as Expo does not update React Native version to 0.64 which supports React v17) reverting to @unform/mobile and @unform/core version 2.1.3 fixes this issue.

zigcccc avatar Feb 11 '21 14:02 zigcccc

@zigcccc dumb question version 2.1.3 in package.json with no caret range right?

luizwhite avatar Feb 11 '21 15:02 luizwhite

@zigcccc dumb question

version 2.1.3 in package.json with no caret range right?

@luizwhite You're correct yep, 2.1.3 without the caret, we need to be specific on what we want here 😊

zigcccc avatar Feb 11 '21 15:02 zigcccc

@zigcccc tks, it worked for me! no errors, and builded correctly!

Reverting @unform/mobile and @unform/core version to 2.1.3 fixes the issue

luizwhite avatar Feb 11 '21 15:02 luizwhite

yarn add @unform/[email protected] @unform/[email protected] it works here

AdeLuigi avatar Feb 13 '21 21:02 AdeLuigi

Estou tomando o mesmo erro. Estranho que antes não tomava esse erro e não mudamos versão da lib. Existe alguma outra alternativa para resolver esse problema sem atualizar a versão do react? Atualizar o react pode ocasionar problemas em outras libs que temos no projeto. Versões do react / react-native: "react": "16.9.0" "react-native": "0.61.5"

diogomaximo avatar Feb 18 '21 13:02 diogomaximo

Estou tomando o mesmo erro. Estranho que antes não tomava esse erro e não mudamos versão da lib. Existe alguma outra alternativa para resolver esse problema sem atualizar a versão do react? Atualizar o react pode ocasionar problemas em outras libs que temos no projeto. Versões do react / react-native: "react": "16.9.0" "react-native": "0.61.5"

Fazendo downgrade dos 2 unform pra 2.1.3

@diogomaximo

luizwhite avatar Feb 18 '21 15:02 luizwhite

Hey guys, thanks for your patience!

We have fixed the issue on #367, and Unform should work correctly with React 16 and 17.

To get the latest update, just run:

yarn add @unform/core@latest @unform/mobile@latest
# or,
npm install @unform/core@latest @unform/mobile@latest

Also, while contributing to the project, always make sure to use English, following the guidelines.

jpedroschmitz avatar Feb 19 '21 20:02 jpedroschmitz

I installed with the command: yarn add @unform/core@latest @unform/mobile@latest

and have these libs:

"@unform/core": "^2.1.6",
"@unform/mobile": "^2.1.6",
"react": "16.13.1",
"react-native": "0.63.4",

and keeps giving the following error:

Error: Unable to resolve module react/jsx-runtime from /home/renato/Desktop/wiser/appwiser/node_modules/@unform/core/dist/index.js: react/jsx-runtime could not be found within the project.

Remato avatar Feb 19 '21 22:02 Remato

I upgraded to the version and it worked normally "@unform/core": "^1.9.8", "@unform/mobile": "^1.9.8",

FelipeFerreiraDev avatar Feb 19 '21 23:02 FelipeFerreiraDev

I installed with the command: yarn add @unform/core@latest @unform/mobile@latest

and have these libs:

"@unform/core": "^2.1.6",
"@unform/mobile": "^2.1.6",
"react": "16.13.1",
"react-native": "0.63.4",

and keeps giving the following error:

Error: Unable to resolve module react/jsx-runtime from /home/renato/Desktop/wiser/appwiser/node_modules/@unform/core/dist/index.js: react/jsx-runtime could not be found within the project.

I'm just delete my yarn.lock and node_modules from my project and upgrade my package.json to:

"@unform/core": "^2.1.6",
"@unform/mobile": "^2.1.6",
"react": "17.0.1",
"react-native": "0.63.4",

finally reinstalled everything using yarn install

and now it's work fine :)

Remato avatar Feb 19 '21 23:02 Remato

Obrigado pelas informações Deu certo usando o expo, e demais libs nas seguintes versões: "expo": "~40.0.0", "react": "16.13.1", "react-dom": "16.13.1", "@unform/[email protected]", "@unform/[email protected]",

procedimento simples: yarn remove @unform/core @unform/mobile

yarn add @unform/[email protected] @unform/[email protected]

elvesw avatar Feb 22 '21 15:02 elvesw

It looks like the problem wasn't fixed correctly. 😞

I'll look at it again and release a new alpha version, so it's possible to test it out.

Thanks for your help!

jpedroschmitz avatar Feb 23 '21 12:02 jpedroschmitz

I was facing this very problem after I recreated my node_modules folder. I tried all solutions suggested here and nothing was working. Then I executed cd android ./gradlew clean and it came back to life!

leonamjlpaula avatar Feb 23 '21 19:02 leonamjlpaula

Tried downgrade to 2.1.3 didn't work either :(

AlexandreBonfim avatar Feb 23 '21 21:02 AlexandreBonfim

Obrigado pelas informações Deu certo usando o expo, e demais libs nas seguintes versões: "expo": "~40.0.0", "react": "16.13.1", "react-dom": "16.13.1", "@unform/[email protected]", "@unform/[email protected]",

procedimento simples: yarn remove @unform/core @unform/mobile

yarn add @unform/[email protected] @unform/[email protected]

this solution worked for me.

rlocatelli9 avatar Feb 27 '21 20:02 rlocatelli9