EXPO React Native - Failed to initialize react-native-reanimated library - react-native

Getting these errors when using Drawer Navigation.
Here is the complete App.js
import { useEffect, useState } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { NavigationContainer } from '#react-navigation/native';
import { createDrawerNavigator } from '#react-navigation/drawer';
import HomePage from './components/Pages/Home.Component';
import SearchPage from './components/Pages/Search.page';
import CardsPage from './components/Pages/Cards';
const Drawer = createDrawerNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomePage} />
<Drawer.Screen name="Search" component={SearchPage} />
<Drawer.Screen name="Cards" component={CardsPage} />
</Drawer.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor:'#fff',
alignItems: 'center',
justifyContent: 'center',
},
navbar:{
marginBottom:'10%'
}
});
babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin'
]
};
};
package.json
{
"name": "talsmandb",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#expo/webpack-config": "^0.17.2",
"#react-native-community/masked-view": "^0.1.11",
"#react-navigation/bottom-tabs": "^6.4.3",
"#react-navigation/drawer": "^6.5.3",
"#react-navigation/native": "^6.0.16",
"#react-navigation/native-stack": "^6.9.4",
"expo": "~47.0.8",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "^2.8.0",
"react-native-reanimated": "^2.12.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "~3.18.0",
"react-native-web": "~0.18.9",
"react-navigation": "^4.4.4"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
If we remove the DrawerNavigation import and change the code to tab then everything works fine.
We have cleared the cache after adding the plugin.
We have completely uninstalled and reinstalled all modules.
What silly mistake have we made?

This worked for me.
npm i react-native-reanimated
Add plugins:['react-native-reanimated/plugin'], below presets in '<your_app_root_folder>/babel.config.js'.
Add import 'react-native-gesture-handler'; to the top of '<your_app_root_folder>/App.js'.
Reset the cache using npx react-native start --reset-cache.

Related

When a styled component is applied to a React Native project using Expo, it is built on the web, but not on the phone

When a styled component is applied to a React Native project using Expo, it is built on the web, but not on the phone.
But if I use StyleSheet.create with the same style, it works fine. Maybe there's something I'm missing out on?
Actions taken to solve the problem
Try lowering the version of the styled component to 5.0.0 or 4.4.3.
Try installing the styled component again.
Make sure my phone and computer are on the same network.
Try logging in to Expo again.
However, all of the above measures were to no avail.
What is the problem?
My App.js
import * as React from "react";
import { StatusBar } from "expo-status-bar";
import { NavigationContainer } from "#react-navigation/native";
import { createNativeStackNavigator } from "#react-navigation/native-stack";
import MainScreen from "./src/screen/MainScreen";
import LoginScreen from "./src/screen/LoginScreen";
export default function App() {
const Stack = createNativeStackNavigator();
return (
<NavigationContainer>
<StatusBar style="auto" />
<Stack.Navigator
initialRouteName="Main"
screenOptions={{ headerShown: false }}
>
<Stack.Screen name="Main" component={MainScreen} />
<Stack.Screen name="Login" component={LoginScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
enter image description here
My Package.json
{
"name": "my-project",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#expo/vector-icons": "^13.0.0",
"#expo/webpack-config": "^0.17.0",
"#react-navigation/native": "^6.0.13",
"#react-navigation/native-stack": "^6.9.1",
"#react-navigation/stack": "^6.3.2",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"expo": "~46.0.13",
"expo-font": "^10.2.1",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-dotenv": "^3.3.1",
"react-native-web": "~0.18.7",
"socket.io-client": "^4.5.2",
"styled-components": "^5.3.6"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"eslint": "^8.25.0",
"eslint-plugin-react": "^7.31.10",
"prettier": "2.7.1"
},
"private": true
}

Tailwaind css in nativewind is not beign applied on Screen components

Tailwind CSS in the native wind is not being applied on Screen components.
Is there any package or dependency that is missing in my project .
This is a package.json
{
"name": "first-app",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-navigation/native": "^6.0.13",
"#react-navigation/native-stack": "^6.9.1",
"expo": "~46.0.13",
"expo-status-bar": "~1.4.0",
"nativewind": "^2.0.11",
"react": "18.0.0",
"react-native": "0.69.6",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"tailwindcss": "^3.2.0"
},
"private": true
}
Tailwind CSS is Applied on App.js but on screens components
import { StatusBar } from 'expo-status-bar';
import { NavigationContainer } from '#react-navigation/native';
import { createNativeStackNavigator } from '#react-navigation/native-stack';
import HomeScreen from './screens/HomeScreen';
export default function App() {
const Stack = createNativeStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
This is Screen Component where native wind ( tailwind ) is not Applied
import { View, Text } from 'react-native'
import React from 'react'
const HomeScreen = () => {
return (
<View className="flex-1 text-center align-middle justify-center">
<Text className="bg-black text-white">App</Text>
</View>
)
}
export default HomeScreen
Firstly my tailwind.config.js Looks like this
module.exports = {
content: ["./App.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}", "./screens/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
}
Then I CHANGED IT WITH FOLLOWING CODE. THE MAIN CHANGE WAS IN content part. By applying the above change tailwindcss started applying both in screens and components. This worked for me
module.exports = {
content:[
"./screens/**/*.{js,jsx,ts,tsx}",
"./pages/**/*.{js,jsx,ts,tsx}",
"./components/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
};

React Native (Android): Couldn't find a 'component', 'getComponent' or 'children' prop for the screen 'Home'

Hoping someone can help as i'm struggling to see what the issue is.
When using react-native-navigation to create a stack navigator, no matter what approach I use to export and import the component to pass into the <Stack.Screen/>, it seems to throw the below error.
React Native Issue
Stack Trace
Error: Couldn't find a 'component', 'getComponent' or 'children' prop for the screen 'Home'. This can happen if you passed 'undefined'. You likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing.
After seeing this stack trace, i done a console.log() and passed in the component just to see if undefined was being returned. This wasn't the case. I can see the HomeComp component for example be
package.json
"name": "myApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/native": "^5.8.0",
"#react-navigation/stack": "^5.10.0",
"axios": "^0.21.0",
"body-parser": "^1.19.0",
"connect-flash": "^0.1.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-validator": "^6.6.1",
"mongoose": "^5.10.10",
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.1",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.12.0"
},
"devDependencies": {
"#babel/core": "7.12.3",
"#babel/runtime": "7.12.1",
"#react-native-community/eslint-config": "1.1.0",
"babel-jest": "25.5.1",
"eslint": "6.8.0",
"jest": "25.5.4",
"metro-react-native-babel-preset": "0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
HomeComp.js
import React, { useState, useEffect } from 'react';
import { View, StyleSheet, Text, FlatList } from 'react-native';
function HomeComp() {
return (
<View>
<Text>Welcome!</Text>
</View>
)
}
const styles = StyleSheet.create({
container: {
//paddingTop: 30,
},
text: {
fontSize: 20,
margin: 10
},
})
export default HomeComp;
app.js
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import HomeComp from './src/components/HomeComp';
// import StatefulComponent from './src/components/api_comp';
import { createStackNavigator } from '#react-navigation/stack';
import { NavigationContainer } from '#react-navigation/native';
// To see all the requests in the chrome Dev tools in the network tab.
XMLHttpRequest = GLOBAL.originalXMLHttpRequest ?
GLOBAL.originalXMLHttpRequest :
GLOBAL.XMLHttpRequest;
// fetch logger
global._fetch = fetch;
global.fetch = function (uri, options, ...args) {
return global._fetch(uri, options, ...args).then((response) => {
console.log('Fetch', { request: { uri, options, ...args }, response });
return response;
});
};
function test(){
return(
<View>
<Text>home page</Text>
</View>
);
}
console.log({HomeComp})
export default class App extends Component {
render() {
Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
Component={HomeComp}
/>
<Stack.Screen
name="test"
Component={test}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#1c8282'
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
}
}); ```
The problem is you are using 'Component' instead of 'component'
you will have to change the prop name to simple case
<Stack.Screen
name="Home"
component={HomeComp}
/>
<Stack.Screen
name="test"
component={test}
/>
As the component prop is not being passed its undefined in the navigator, thats why you are getting the error

Type Error when trying Stack Navigator from React Navigation

I'm running the example below locally but get a TypeError.
import HomeScreen from './screens/HomeScreen';
import SecoundScreen from './screens/SecoundScreen';
import ThirdScreen from './screens/ThirdScreen';
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
const Stack = createStackNavigator();
function MyStack() {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Second" component={SecoundScreen} />
<Stack.Screen name="Third" component={ThirdScreen} />
</Stack.Navigator>
);
}
export default function App() {
return (
<NavigationContainer>
<MyStack />
</NavigationContainer>
);
}
I copied the from the example, and it didn't work before I modified it either # https://reactnavigation.org/docs/en/stack-navigator.html
https://snack.expo.io/?platform=android&name=createStackNavigator%20%C2%B7%20React%20Navigation&dependencies=%40react-native-community%2Fmasked-view%40%5E0.1.1%2C%40react-navigation%2Fnative%40%5E5.0.0%2C%40react-navigation%2Fbottom-tabs%40%5E5.0.0%2C%40react-navigation%2Fdrawer%40%5E5.0.0%2C%40react-navigation%2Fmaterial-bottom-tabs%40%5E5.0.0%2C%40react-navigation%2Fmaterial-top-tabs%40%5E5.0.0%2C%40react-navigation%2Fnative-stack%40%5E5.0.0%2C%40react-navigation%2Fstack%40%5E5.0.0%2Creact-native-gesture-handler%401.5.2%2Creact-native-reanimated%401.4.0%2Creact-native-safe-area-context%400.6.0%2Creact-native-screens%402.0.0-alpha.12&sourceUrl=https%3A%2F%2Freactnavigation.org%2Fexamples%2F5.x%2Fsimple-stack.js
The code below is working! I just installed react-navigation, so I should have the latest version!
import React, { useState } from 'react';
import { Button, View } from 'react-native';
import HomeScreen from './screens/HomeScreen';
import SecondScreen from './screens/SecondScreen';
import ThirdScreen from './screens/ThirdScreen';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
const AppNavigator = createStackNavigator(
{
Home: HomeScreen,
Second: SecondScreen,
Third: ThirdScreen
},
{
initialRouteName: 'Home',
}
);
export default createAppContainer(AppNavigator);
Any idea why the first version is failing?
package.json before and after npm update:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "0.1.5",
"#react-navigation/stack": "^5.0.0",
"expo": "~36.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-gesture-handler": "~1.5.0",
"react-native-paper": "^3.6.0",
"react-native-reanimated": "~1.4.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7",
"react-navigation": "^4.1.1",
"react-navigation-fluid-transitions": "^0.3.2",
"react-navigation-stack": "^2.1.1"
},
"devDependencies": {
"babel-preset-expo": "~8.0.0",
"#babel/core": "^7.0.0"
},
"private": true
}
I needed to update the dependencies, this did the trick:
$ npm install -g npm-check-updates
$ npm-check-updates -u
$ npm install

I am having an issue loading the Icon library from react-native-elements

I am unable to use the Icon component from react-native-vector-icons. I was able to use it before with no issues, but now when I import the Icon component into my App.js file that I created with Expo, I get an error.
I have already uninstalled and reinstalled Expo, uninstalled and reinstalled react-native-elements, and created a new Expo project.
Here is my App.js file from Expo. The only thing that is changed from the default App.js file is the import of the Icon and the Button components. The Button component renders correctly.
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Icon, Button } from 'react-native-elements';
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Button title='hello' />
<Icon
name='g-translate'
color='#00aced'
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
And here is my package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^33.0.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.11.4"
},
"devDependencies": {
"babel-preset-expo": "^5.1.1"
},
"private": true
}
I get the error [Unhandled promise rejection: Error: Directory for file:///Users/{myusername}/Library/Developer/CoreSimulator/Devices/CE65DD4F-AFFE-46F7-A173-6B25AF30CBCE/data/Containers/Data/Application/DB21F77C-3BE4-470E-AA62-52E6C8376F0C/Library/Caches/ExponentExperienceData/%2540psoren%252FOctave/ExponentAsset-b06871f281fee6b241d60582ae9369b9.ttf doesn't exist.]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:155:41 in createErrorFromErrorData
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:104:55 in