7

我无法解决这个问题,并浏览了以下文档 https://www.npmjs.com/package/react-native-tab-view

在此处输入图像描述

我也没有遇到任何关于这个问题的文件。我使用了上面链接中提到的相同示例代码。

import * as React from 'react';
import { View, StyleSheet, Dimensions } from 'react-native';
import { TabView, SceneMap } from 'react-native-tab-view';
 
const FirstRoute = () => (
  <View style={[styles.scene, { backgroundColor: '#ff4081' }]} />
);
 
const SecondRoute = () => (
  <View style={[styles.scene, { backgroundColor: '#673ab7' }]} />
);
 
const initialLayout = { width: Dimensions.get('window').width };
 
export default function TabViewExample() {
  const [index, setIndex] = React.useState(0);
  const [routes] = React.useState([
    { key: 'first', title: 'First' },
    { key: 'second', title: 'Second' },
  ]);
 
  const renderScene = SceneMap({
    first: FirstRoute,
    second: SecondRoute,
  });
 
  return (
    <TabView
      navigationState={{ index, routes }}
      renderScene={renderScene}
      onIndexChange={setIndex}
      initialLayout={initialLayout}
    />
  );
}
 
const styles = StyleSheet.create({
  scene: {
    flex: 1,
  },
});

我该如何解决这个问题?

npm version is 6.14.4
React-native version is 0.62.2
react-native-tab-view: "^2.15.0"
react-native-gesture-handler: "^1.6.1"
react-native-reanimated: "^1.10.1"
@react-native-community/masked-view: "^0.1.10"
4

3 回答 3

2

运行npm i react-native-gesture-handler@1.7.0。清除缓存并重新构建。

0.59 版不需要链接,因为它会自动链接依赖项。

于 2021-03-07T07:39:55.793 回答
0

将 react-native-gesture-handler 升级到 1.7.0

于 2020-08-03T09:00:27.123 回答
0

使用react-native link react-native-reanimated 然后点击此链接 https://github.com/software-mansion/react-native-reanimated/blob/master/Example/android/app/src/main/java/com/swmansion/reanimated/example/MainApplication。爪哇

于 2020-08-03T08:44:02.600 回答