【发布时间】:2019-08-06 23:03:24
【问题描述】:
在升级到最新版本的 React-Native 和 Expo 之前,此代码块正在运行。它正在使用的版本是"expo": "^32.0.0"。
我以前能够以编程方式移动 Animated.ScrollView 的子项,但现在我无法再这样做了。这是我正在测试的测试代码块。
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Animated,
TouchableOpacity,
SafeAreaView,
ScrollView
} from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
}
handleMove = () => {
this.scroller.getNode().scrollTo({
x: 200,
y: 0,
animated: false
});
};
render() {
return (
<SafeAreaView style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Animated.ScrollView
horizontal
ref={scroller => {
this.scroller = scroller;
}}
>
<View
style={{
height: 100,
width: 100,
backgroundColor: 'red',
margin: 5
}}
/>
</Animated.ScrollView>
<TouchableOpacity onPress={this.handleMove}>
<Text>Move</Text>
</TouchableOpacity>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {}
});
升级后的代码块不再适用于最新版本。我正在测试的当前版本是:
"dependencies": {
"expo": "^34.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"react-native-web": "^0.11.4"
},
这样做的正确方法是什么?
我添加了一份零食来帮助说明我的问题。 ' https://snack.expo.io/@louis345/brave-banana
【问题讨论】: