Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Error using Form from @unform/mobile #356

Open
MullerEsposito opened this issue Jan 30, 2021 · 40 comments · Fixed by #367
Open

Error using Form from @unform/mobile #356

MullerEsposito opened this issue Jan 30, 2021 · 40 comments · Fixed by #367
Assignees

Comments

@MullerEsposito
Copy link

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

@fermaiasoares
Copy link

fermaiasoares commented Jan 30, 2021

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.

@andredezzy
Copy link

@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.

@Jonathansoufer
Copy link

Jonathansoufer commented Jan 31, 2021

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

@andredezzy
Copy link

@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.

@patricpfranca
Copy link

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",

@lccoronel
Copy link

lccoronel commented Feb 2, 2021

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

@gbfonseca
Copy link

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.

@MullerEsposito
Copy link
Author

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.

@carlos-eugenio
Copy link

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.

@bralandealmeida
Copy link

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

@jjairojr
Copy link

jjairojr commented Feb 5, 2021

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

@patricpfranca
Copy link

@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.

@bralandealmeida
Copy link

@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.

@carlos-eugenio
Copy link

carlos-eugenio commented Feb 8, 2021

@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.

@zigcccc
Copy link

zigcccc commented Feb 11, 2021

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.

@luizwhite
Copy link

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

@zigcccc
Copy link

zigcccc commented Feb 11, 2021

@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 😊

@luizwhite
Copy link

@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

@AdeLuigi
Copy link

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3 it works here

@diogomaximo
Copy link

diogomaximo commented Feb 18, 2021

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"

@luizwhite
Copy link

luizwhite commented Feb 18, 2021

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

@jpedroschmitz
Copy link
Member

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.

@Remato
Copy link

Remato commented Feb 19, 2021

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.

@FelipeFerreiraDev
Copy link

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

@Remato
Copy link

Remato commented Feb 19, 2021

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 :)

@elvesw
Copy link

elvesw commented Feb 22, 2021

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/core@2.1.3",
"@unform/mobile@2.1.3",

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

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3

@jpedroschmitz
Copy link
Member

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 jpedroschmitz reopened this Feb 23, 2021
@jpedroschmitz jpedroschmitz self-assigned this Feb 23, 2021
@leonamjlpaula
Copy link

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!

@AlexandreBonfim
Copy link

Tried downgrade to 2.1.3 didn't work either :(

@rlocatelli9
Copy link

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/core@2.1.3",
"@unform/mobile@2.1.3",

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

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3

this solution worked for me.

@victorseibert
Copy link

victorseibert commented Mar 3, 2021

Tried downgrade to 2.1.3 didn't work either :(

Neither for me :/

But on the repo they linked an snak that uses "@unform/core": "1.9.8" and "@unform/mobile": "1.9.8" for expo": "~40.0.0", "react": "16.13.1" and "react-dom": "16.13.1".

I download it an works fine, but dosen't on my project...

This is very confusin, on the migration page they say Unform 2.0 added support for React Native.

@andregodasi
Copy link

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 thank you, his approach worked.

@GusPrado
Copy link

Version 2.1.3 of @mobile and @core worked fine with React 16.13.1 here. The latest 2.1.6 still doesn't works with React 16.

@adrianlivr
Copy link

The same here. Expo with react 16.13.1 and unform 2.1.3 work, but unform 2.1.6 doesn't

@Pedroor
Copy link

Pedroor commented Mar 22, 2021

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3 it works here

God

@luizwhite
Copy link

I can confirm that the last version works with:

"react": "17.0.1",
"react-native": "0.64.0",

@allanzi
Copy link

allanzi commented Jun 3, 2021

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3 it works here

Works for me ✌️

@leoarmelin
Copy link

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/core@2.1.3",
"@unform/mobile@2.1.3",

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

yarn add @unform/core@2.1.3 @unform/mobile@2.1.3

This solution worked for me!

Environment:
"expo": "~41.0.1",
"react": "16.13.1",
"react-dom": "16.13.1",

@jonyreisxyz
Copy link

This solution worked for me!

Environment:
"@unform/core": "^2.1.3",
"@unform/mobile": "^2.1.3",
"expo": "~41.0.1",
"react": "17.0.1",
"react-dom": "17.0.1",

@EuclidesQuissembe
Copy link

This solution worked for me!

Environment:
"react": "17.0.1",
"react-dom": "17.0.1",

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

Successfully merging a pull request may close this issue.