Tree shake moti/skeleton
from Expo, improve performance
#267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test this PR
At the time of writing, the version is
0.24.0-alpha.10
.This PR seeks to improve
moti/skeleton
in a few ways:Tree shake expo
A few people have complained that they can't use the skeleton without installing
expo-linear-gradient
.You can now choose between the following gradient libraries:
expo-linear-gradient
react-native-linear-gradient
This addresses #237.
To use
react-native-linear-gradient
add this to your app'sbabel.config.js
'splugins
array.Improve performance
Next, hoping to address #251 if possible.
While it's hard to narrow down perf issues, especially in development, there are a few obvious wins I'll be pursuing:
useSharedValue
to improve render performance and trigger zero re-renders. This wasn't possible in old versions of Moti, but now it is.useAnimatedStyle
,useSharedValue
,Animated.View
, etc. I'm trying to reduce these where possible.AnimatePresence
in favor of a simple opacity animation. This will leave an additional animated view mounted, but it will not loop continuously, so it shouldn't affect performance.If you want to optimize performance even more, try passing
disableExitAnimation={true}
. This will, of course, disable the exit animation, so it might not feel as smooth.Web
I might leave this for a later PR, but maybe web could benefit from using CSS transitions directly. We'd lose all control though, so not sure if it's the right move or not.