unform
unform copied to clipboard
Error using Form from @unform/mobile
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
fromnode_modules/@unform/mobile/dist/index.js
: react/jsx-runtime could not be found within the project."
_
To Reproduce
- Install the @unform/mobile dependency: yarn add @unform/mobile
- Import on React page the Form component: import { Form } from "@unform/mobile"
- Call the Form component in some form:
<Form onSubmit={anyFunction}> <Input /> <Button>Enviar</Button> </Form>
- 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
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
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 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.
Use a versão ^2.1.3 ao invés da ^2.1.4 e atualize o react para a v17.
@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.
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",
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
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.
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.
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.
Tive o mesmo problema aqui no react native. Resolvi conforme as respostas acima.
@carlos-eugenio @bralandealmeida como ficou a versão de vocês do RN - React e @unform/mobile e /core ? to passando pelo msm problema...
@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.
@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 @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.
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 dumb question version 2.1.3 in package.json with no caret range right?
@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 tks, it worked for me! no errors, and builded correctly!
Reverting @unform/mobile and @unform/core version to 2.1.3 fixes the issue
yarn add @unform/[email protected] @unform/[email protected]
it works here
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"
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
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.
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 upgraded to the version and it worked normally
"@unform/core": "^1.9.8",
"@unform/mobile": "^1.9.8",
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 :)
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]
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!
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!
Tried downgrade to 2.1.3 didn't work either :(
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.