question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using useAnimatedStyle with contentContainerStyle inside Animated.ScrollView

See original GitHub issue

Description

I want to update the height of my ScrollView when adding an item but I keep getting Property is not configurable. What is the correct way to pass this value ?

Code

const height = useDerivedValue(() => {
    return items.length * 200
}, [items])

const style = useAnimatedStyle(() => ({
    height: height.value
}))

return <Animated.ScrollView contentContainerStyle={[style]}> ... </Animated.ScrollView>

Package versions

  • React: 16.13.1
  • React Native: 0.63.2
  • React Native Reanimated: 2.0.0-alpha.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
terrysahaidakcommented, Oct 13, 2020

Oh, I guess this won’t work, I didn’t read carefully your description, sorry.

The contentContainerStyle is a prop that is passing to the underlying view that wraps the content of Scroll view. That view is not animated - that’s why you can’t pass animated styles to it. But you can create your own container - just wrap the children of the ScrollView with your own animated view.

1reaction
terrysahaidakcommented, Oct 13, 2020

seems like it’s related to the limitations of capturing object to be used on UI Thread. It doesn’t capture prototype property which causes iterations on these objects to not work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollHandler and scrollTo in animated scrollview
Try this one: link. You can simply add another animated variable and set it to true before scrolling and set it to false...
Read more >
useAnimatedKeyboard | React Native Reanimated
With the useAnimatedKeyboard hook, you can create animations based on current keyboard position. On Android, make sure to set android:windowSoftInputMode in ...
Read more >
ScrollView
Component that wraps platform ScrollView while providing integration with touch locking "responder" system. Keep in mind that ScrollViews must have a ...
Read more >
Chanel Scroll Animation - “Can it be done in React Native?”
Learn React Native Gestures and Animations at https://start-react-native.dev/Source code: ...
Read more >
How to smoothly animate your react native app
React native comes with a built-in library called animated. ... To do so, we'll use the scroll event from our ScrollView to make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found