首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不变违反:TurboModuleRegistry.getEnforcing(.):无法找到'NativeReanimated‘

不变违反:TurboModuleRegistry.getEnforcing(.):无法找到'NativeReanimated‘
EN

Stack Overflow用户
提问于 2021-01-17 13:14:04
回答 7查看 9.9K关注 0票数 6

因此,这是我第一次使用Reanimated 2,不幸的是,我的应用程序因上面的消息而崩溃。无法查看我的应用程序屏幕。

不变违反:TurboModuleRegistry.getEnforcing(.):无法找到'NativeReanimated‘。验证此名称的模块是否已在本机二进制文件中注册。

我在这里用的是动画

代码语言:javascript
复制
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:

代码语言:javascript
复制
{
  "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"
  }
}
EN

回答 7

Stack Overflow用户

发布于 2021-03-10 04:40:11

更新包不是自动链接在android中,请按照正式文档中提到的步骤进行操作。

你需要改变android/app/build.gradle

代码语言:javascript
复制
project.ext.react = [
 enableHermes: true,  // clean and rebuild if changing
]

在babel.config.js中添加以下内容

代码语言:javascript
复制
plugins: ['react-native-reanimated/plugin']

在MainApplication.java中添加以下内容

代码语言:javascript
复制
    @Override
    protected JSIModulePackage getJSIModulePackage() {
      return new ReanimatedJSIModulePackage(); // <- add
    }
票数 4
EN

Stack Overflow用户

发布于 2021-03-23 10:38:09

我把"react-native-reanimated": "2.0.0"降到了"react-native-reanimated": "1.13.0"

过去在终点站yarn add react-native-reanimated@1.13.0npm install react-native-reanimated@1.13.0 --save

已修复。

票数 1
EN

Stack Overflow用户

发布于 2021-03-22 22:23:12

我也曾经历过and本机^0.64.0和React导航5.x的相同问题。

如正式文档中所述,恢复依赖关系需要一些额外的信任,包括MainApplication.java "react-native-reanimated": "^2.0.0"Hermesbabel

请按照官方文件来解决反应本土化

除了向package.json添加依赖项之外,还需要其他步骤

修改后,一定要清除花纹和纱线(或npm )缓存。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65761015

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档