Lou*_*345 8 scrollview react-native
在升级到最新版本的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: {}
});
Run Code Online (Sandbox Code Playgroud)
升级后,代码块不再适用于最新版本。我正在测试的当前版本是:
"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"
},
Run Code Online (Sandbox Code Playgroud)
正确的做法是什么?
我添加了点心来说明我的问题。' https://snack.expo.io/@louis345/brave-banana
| 归档时间: |
|
| 查看次数: |
594 次 |
| 最近记录: |