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 {View} from 'react-native'
import {observer} from 'mobx-react-lite'
import Animated, {useAnimatedScrollHandler} from 'react-native-reanimated'
export default function App() {
@@ -9,13 +10,16 @@ export default function App() {
return () => clearInterval(id)
}, [])
// props to pass into children render functions
const onScroll = useAnimatedScrollHandler({
onScroll(e) {
const handler = useAnimatedScrollHandler({
onScroll() {
console.log(x)
},
})
return <Child onScroll={handler} />
}
const Child = observer(function ({onScroll}) {
return (
<View style={{flex: 1, flexDirection: 'row'}}>
<Animated.FlatList
@@ -25,13 +29,6 @@ export default function App() {
paddingTop: 1000,
}}
/>
<Animated.FlatList
onScroll={onScroll}
style={{flex: 1, backgroundColor: 'blue'}}
contentContainerStyle={{
paddingTop: 1000,
}}
/>
</View>
)
}
})