show bug with mobx

This commit is contained in:
Dan Abramov
2023-11-10 15:50:22 +00:00
parent a3348aca15
commit 2cc26cf805
+8 -11
View File
@@ -1,5 +1,6 @@
import * as React from 'react' import * as React from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {observer} from 'mobx-react-lite'
import Animated, {useAnimatedScrollHandler} from 'react-native-reanimated' import Animated, {useAnimatedScrollHandler} from 'react-native-reanimated'
export default function App() { export default function App() {
@@ -9,13 +10,16 @@ export default function App() {
return () => clearInterval(id) return () => clearInterval(id)
}, []) }, [])
// props to pass into children render functions const handler = useAnimatedScrollHandler({
const onScroll = useAnimatedScrollHandler({ onScroll() {
onScroll(e) {
console.log(x) console.log(x)
}, },
}) })
return <Child onScroll={handler} />
}
const Child = observer(function ({onScroll}) {
return ( return (
<View style={{flex: 1, flexDirection: 'row'}}> <View style={{flex: 1, flexDirection: 'row'}}>
<Animated.FlatList <Animated.FlatList
@@ -25,13 +29,6 @@ export default function App() {
paddingTop: 1000, paddingTop: 1000,
}} }}
/> />
<Animated.FlatList
onScroll={onScroll}
style={{flex: 1, backgroundColor: 'blue'}}
contentContainerStyle={{
paddingTop: 1000,
}}
/>
</View> </View>
) )
} })