所以这是我第一次使用复活2,不幸的是我的应用程序得到崩溃与上述消息。无法查看我的应用程序屏幕。
不变违例:TurboModuleRegistry.getEnforcing(...):找不到“NativeReanimated”。验证此名称的模块是否已在本机二进制文件中注册。
我在这里用的是复活
import React from 'react'
import Item from '../../Common/Item'
import {View,Text,FlatList,StyleSheet , TouchableOpacity} from 'react-native'
import Animated, {useAnimatedStyle} from 'react-native-reanimated';
import {bin,mix,useTiming} from 'react-native-redash'
const {interpolate,not}=Animated
const SectorItem=({sector,clients,index,opened,toggleSector})=> {
const {name}=sector
const ITEM_HEIGHT = 100
const transition = useTiming(opened)
const style = useAnimatedStyle(()=>({
height: mix(transition,0,clients.length * ITEM_HEIGHT)
}))
//here we wll also have the clients of each sector
return <Item xStyle={styles.item}>
<View>
<Text>{name}</Text>
<TouchableOpacity onPress={e=>toggleSector(index)}>
<Text>open</Text>
</TouchableOpacity>
</View>
<Animated.View style={style}>
<FlatList
data = {clients}
style = {{...styles.Clientlist,display:opened?'flex':'none'}}
contentContainerStyle = {props =>(styles.flatList)}
showsVerticalScrollIndicator={false}
renderItem = {({ item }) =><Item xStyle={{marginBottom:8}}>
<TouchableOpacity>
{/* redirect to client */}
<Text>{item.name} </Text>
</TouchableOpacity>
</Item> }
keyExtractor = {(item, index) => index.toString()}
/>
</Animated.View>
</Item>
}
export default SectorItem
var styles = StyleSheet.create({
list:{
borderColor:'#fff',
padding:16,
},
Clientlist:{
borderColor:'#fff',
padding:16,
},
flatList:{
alignItems: 'center',
justifyContent: 'center',
height:200,
flex:1
},
item:{
marginBottom:8
}
});
我的package.json:
{
"name": "DistributionApp",
"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/drawer": "^5.11.5",
"@react-navigation/native": "^5.9.0",
"@react-navigation/stack": "^5.13.0",
"@rematch/core": "^2.0.0-next.10",
"cross-fetch": "^3.0.6",
"nanoid": "^3.1.20",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-elements": "^3.1.0",
"react-native-fast-image": "^8.3.4",
"react-native-gesture-handler": "^1.9.0",
"react-native-reanimated": "^2.0.0-rc.2",
"react-native-redash": "^16.0.8",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.16.1",
"react-redux": "^7.2.2",
"redux": "^4.0.5",
"typescript": "^4.1.3"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
8条答案
按热度按时间z4iuyo4d1#
reanimated包在android中没有自动链接,请按照官方文档中提到的步骤操作。
您需要在android/app/build.gradle中进行更改
在babel.config.js中添加以下内容
在www.example.com中添加以下MainApplication.java
6tdlim6h2#
我把
"react-native-reanimated": "2.0.0"
降到了"react-native-reanimated": "1.13.0"
过去在终端
yarn add react-native-reanimated@1.13.0
或npm install react-native-reanimated@1.13.0 --save
修好了
kpbwa7wx3#
我在使用React Native
^0.64.0
和react-navigation5.x
时也遇到过同样的问题。官方文档中提到的复活依赖
"react-native-reanimated": "^2.0.0"
需要一些额外的配置,包括***babel***、爱马仕***和***MainApplication.java请按照官方文档解析React Native Reanimated
除了将依赖项添加到package.json之外,还需要其他步骤
在进行更改后,确保清除gradle和yarn(或npm)缓存
gkn4icbw4#
遵循官方guid帮助我doc
gywdnpxw5#
运行
npx react-native link react-native-reanimated
为我解决了这个问题。似乎这将以下行添加到ios/Podfile:
pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
toe950276#
iOS版
注意:我使用Xcode版本13.4.1(13 F100)并在Mac M1中运行应用程序。
我认为这个错误就像我得到的一样,我得到了这个错误:
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'ImageLoader' could not be found
我在Exclude Architectures -> Debug -> Any SDK中添加
arm64,amv7
修复了错误s3fp2yjn7#
在我的情况下,这是因为我没有安装pod。我通过移动到ios目录并运行podinstall解决了这个问题
8iwquhpp8#
我得到了这个
TurboModuleRegistry.getEnforcing(...): 'NativeReanimated'
错误,并找到了解决方案:第一步-从github下载react native项目:https://github.com/software-mansion-labs/reanimated-2-playground
第二步-然后运行命令
构建App
步骤3-当它工作时,移动所需的项目文件并安装所需的npm包。
步骤4-然后运行命令