No dimensions set for key window - react-native

I am having some issues with react native. It keeps giving me the following error.
What could be causing this?

Try closing terminal, deleting ios/build and run again. I had the same issue but now its working.

For anyone that runs into this. Check to confirm the window passed to get() is a string Dimensions.get('window') .

There apparently is an issue with react-router-flux since a few days.
You probably need to rollback to the 3.38.0 version before the bug was introduced.
yarn add react-native-router-flux#3.38.0
If it doesn't work, some people also said that you might need to close all your terminals, delete your build folder and clear your npm cache.

I got this error when I ran a different react-native project, but had forgotten to close the terminal window that was running the React Packager. Once I closed the React Packager terminal window and re-ran react-native run-android the error went away.

Check if you have an old package manager running from a different project. If so, close it and run again.

Close all terminal
and after use following command in terminal
npm cache clean
worked for me

"Close terminal, rerun" worked for me. Seems like this is a recent issue due to the update of react-native.

There are another way to solve this error, I update react-native-cli: 2.0.1 and it works for me.

Use this Dimensions.get('window').width;

Related

React Native TextInput closes automatically when opened on android

I switched laptops and cloned the repository of my project, did a quick yarn install and looks like it was a big difference from the one on the main branch but I didn't bother since maybe it's just because of different Node versions.
Now every time I click on one TextInput the keyboard opens and closes immediately only on android. I attached a quick recording here. Tried some solutions and it looks like switching android:windowSoftInputMode from adjustResize to adjustPan in AndroidManifest.xml fixes the problem with the closing but I'm not really happy with the behaviour of the keyboard in the app when it's set to adjustPan. Maybe this issue starting happening a while ago but I just saw it now.
Here is just an input centered inside a simple View.
https://gfycat.com/ordinaryquestionabledinosaur
Any suggestions anyone?
Was facing a similar issue, turned out that the react-native-screens library was causing the problem. Try setting the version to "~3.10.2". Worked out for me.
Change the line in AndroidManifest.xml
Old line
android:windowSoftInputMode="adjustResize"
New line
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Change the line in AndroidManifest.xml works for me, I did the update but that does not works
Change the config to:
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Replace the line in the AndroidManifest.xml file:
Before
android:windowSoftInputMode="adjustResize"
After
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Just Upgraded react-native-screen to latest version.
yarn add react-native-screens
"react-native-screens": "^3.13.1"
For those who have the same problem, having both botton and top padding often result on the keyboard closing itself when opening. Took a while to discover that
if you're using react native version "0.64.*". Just set react-native-screens version to "3.4.0". Do not use "^" to avoid npm updated it. and it worked for me.

TypeError: global.__reanimatedWorkletInit is not a function. (In 'global.__reanimatedWorkletInit(_f)', 'global.__reanimatedWorkletInit' is undefined)

TypeError: global.__reanimatedWorkletInit is not a function. (In 'global.__reanimatedWorkletInit(_f)', 'global.__reanimatedWorkletInit' is undefined)
I am using React Native (not expo). I don't even have reanimated downloaded. I had it downloaded then I removed it and rebuilt the app, and it's giving me this error now.
Things I've tried:
deleting node_modules and re-running yarn install
-git reset HEAD~ to a prev commit where I didn't install the reanimated2 packages
I just followed the below steps to solve this issue.
step1: npx react-native run-android
step2: npm start -- --reset-cache
and it solved
Ok, what I ended up doing to solve this was:
-just deleted the whole repo from my local
-cloned it again from github
-uninstalled the app from Android emulator
Then it seemed to work. So maybe it was an error related to cache or something lingering around even after I had removed all instances of the word/package "reanimated" from the whole codebase.
Using Expo in a bareworkflow
Clear app memory
run expo start --dev-client --clear
I solved my issue doing this:
https://github.com/wcandillon/react-native-redash/issues/395
On top you just have to do this: import 'react-native-reanimated';
on your app or index file.
I have tried all the solutions from stack Overflow. (Not working)
Here is the fix:
first check your version for react-native-reanimated and then see the actual documentation of the right version for the configuration.
I am using version 2.4.1 and have solved by this link
I had a require cycle warning from a git submodule inside the src folder which I thought wasn't doing any harm but turns out fixing that solved this issue. I am unsure why the require cycle was causing so much grief but I guess if you've got a require cycle in your output try solving that and it may fix this.
What I did was degrading react-native-reanimated to ^2.6.0. It solved the issue for me.
I had this problem too and simply moved the babel plugin react-native-reanimated/plugin to the last place in the babel's config as stated in the doc.
I should probably mention it worked for me before but when I started migrating the react-native app for web this was the problem for me. I am using expo. I had to run expo with --clear CLI arg as expo start --dev-client --clear.
I Just solved this issue by doing these steps:
close Metro bundler
run this command
npm start -- --reset-cache
react-native start --reset-cache
rebuild the project again

Expo: Can't find variable require

Dear stackoverflow community,
I'm not able to find any solution online for my problem. My error is the following:
Can't find variable: require
http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:5:24
global code#http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:701:3
Screenshot Expo Error
It was working perfectly 2 days ago, and (apparently) I didn't change anything since then.
Do you have any idea where it can come from?
I'm using:
expo#~3.0.10
react-native "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz"
Very basic configuration. I'm suspecting some kind of miss configuration...
Thanks in advance!
Regards,
Guillaume
Updates 09-02-2020 4pm20:
I tried cleaning caches,
I tried changing directory,
I tried expo init a new app, importing the sources of the previous app, installing dependencies, it worked until I ran expo start -c, then the problem came back,
Still working on it...
Updates 09-02-2020 7pm:
I finally succeed to make it work.
Update expo-cli to the latest version
Initialize a new expo app in another directory
Copy/paste source code
Use expo start -c instead of expo start to make sure no cache is involved in the following steps
Install dependencies one by one to make sure none is the problem
Finally test the app
try by adding, import React from 'react' in the file where you mentioned require
first : expo r -c ,
then : npm start,
finally: use require function

undefined is not a function(evaluation 'object.getOwnPropertyDescriptors(arguments[i])')

I'm trying to run an app which I take from git. I ran npm install and react-native run-android then it occurred an error:
I have found solution on Internet for 2 days but there is no result. Can anyone fix this error please?
There's an actual workaround for this, and it worked for me. Try to activate Debug Js Remotely on your developer options, Reload and your app will work. As I said it's a work around, but you can continue working on your app

react-navigation import problems

I have installed and linked react-navigation into my project and somehow when I try importing it to my App.js code, it is showing me errors. I tried doing it many ways, none of which worked. I will be glad if you could help me resolve this issue.
This is the error I am getting in my Terminal window.
Thanks for your help.
This is my code
Since the error says its unable to find the files located in your node_modules chances are node modules are not correctly installed. Try re-installing node modules. It will fix the problem.
You need to reset the cache.
react-native start --reset-cache or npm start -- --reset-cache.
You can check the issue here.