Skip to content

Commit 4278437

Browse files
peachbitsclaude
andcommitted
Remove reanimated v3/v4 split; enable new architecture on Android
Android ran reanimated 3 via the local `r3-hack` package on the old architecture while iOS ran reanimated 4 on Fabric. Reanimated 4 requires the new architecture, so route both platforms through reanimated 4 / worklets and enable the new architecture on Android: - babel.config.js: always use react-native-worklets/plugin; add api.cache(true) now that the config is static (no platform branch configuring the cache). - metro.config.js: drop the r3-hack Android resolver. - react-native.config.js: drop the reanimated sourceDir override and the worklets Android disable. - package.json: remove the r3-hack dependency; delete scripts/r3-hack. - android/gradle.properties: newArchEnabled=true. - useCarouselGesture: unify the withSpring config to the reanimated-4 algorithm on both platforms (Android previously used the reanimated-3 damping). Also dedupe yaob to ^0.4.0, fixing the nativeIo collision that crashed ZEC/Pirate wallet creation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 74f469c commit 4278437

10 files changed

Lines changed: 10 additions & 170 deletions

File tree

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a
3737
# your application. You should enable this flag either if you want
3838
# to write custom TurboModules/Fabric components OR use libraries that
3939
# are providing them.
40-
newArchEnabled=false
40+
newArchEnabled=true
4141

4242
# Use this property to enable or disable the Hermes JS engine.
4343
# If set to false, you will be using JSC instead.

babel.config.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
module.exports = function (api) {
2-
const isAndroid = api.caller(c => c.platform === 'android')
3-
2+
api.cache(true)
43
return {
54
presets: ['module:@react-native/babel-preset'],
6-
plugins: [
7-
isAndroid
8-
? './node_modules/r3-hack/node_modules/react-native-reanimated/plugin'
9-
: 'react-native-worklets/plugin'
10-
]
5+
plugins: ['react-native-worklets/plugin']
116
}
127
}

metro.config.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
22
const {
33
wrapWithReanimatedMetroConfig
44
} = require('react-native-reanimated/metro-config')
5-
const r3Paths = require('r3-hack')
65

76
const defaultConfig = getDefaultConfig(__dirname)
87
const { assetExts, sourceExts } = defaultConfig.resolver
@@ -20,30 +19,6 @@ const config = {
2019
)
2120
},
2221
resolver: {
23-
resolveRequest(context, moduleName, platform) {
24-
if (platform === 'android') {
25-
// Use Reanimated 3 on Android:
26-
const filePath = r3Paths[moduleName]
27-
if (filePath != null) {
28-
return { type: 'sourceFile', filePath }
29-
}
30-
31-
// Ensure we aren't missing any reanimated 3 -> 4 mappings:
32-
if (
33-
moduleName.startsWith('react-native-reanimated') ||
34-
moduleName.startsWith('react-native-worklets')
35-
) {
36-
console.log(
37-
`Could not find "${moduleName}". Please update r3-hack to include it.`
38-
)
39-
return { type: 'empty' }
40-
}
41-
}
42-
43-
// Otherwise use the normal Metro resolution:
44-
return context.resolveRequest(context, moduleName, platform)
45-
},
46-
4722
// From react-native-svg-transformer:
4823
assetExts: assetExts.filter(ext => ext !== 'svg'),
4924
sourceExts: [...sourceExts, 'svg']

package-lock.json

Lines changed: 1 addition & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"*.{js,jsx,ts,tsx}": "eslint"
6464
},
6565
"overrides": {
66+
"yaob": "^0.4.0",
6667
"bip39": "3.0.4"
6768
},
6869
"dependencies": {
@@ -120,7 +121,6 @@
120121
"posthog-react-native": "^2.8.1",
121122
"prompts": "^2.4.2",
122123
"qrcode-generator": "^1.4.4",
123-
"r3-hack": "./scripts/r3-hack",
124124
"react": "19.0.0",
125125
"react-native": "0.79.2",
126126
"react-native-airship": "^0.3.0",

react-native.config.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@ module.exports = {
44
platforms: {
55
ios: null
66
}
7-
},
8-
9-
// We want Reanimated 3 on Android:
10-
'react-native-reanimated': {
11-
platforms: {
12-
android: {
13-
sourceDir:
14-
'../node_modules/r3-hack/node_modules/react-native-reanimated/android'
15-
}
16-
}
17-
},
18-
19-
// We don't want Reanimated 4 worklets on Android:
20-
'react-native-worklets': {
21-
platforms: {
22-
android: null
23-
}
247
}
258
}
269
}

scripts/r3-hack/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/r3-hack/index.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

scripts/r3-hack/package.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/hooks/useCarouselGesture.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Platform } from 'react-native'
21
import { Gesture, type PanGesture } from 'react-native-gesture-handler'
32
import {
43
type SharedValue,
@@ -51,16 +50,11 @@ export const useCarouselGesture = (
5150
0,
5251
Math.min(itemCount - 1, startIndex.value + delta)
5352
)
54-
scrollIndex.value = withSpring(
55-
destValue,
56-
Platform.OS === 'android'
57-
? { damping: 12 } // Old Reanimated 3 algorithm
58-
: {
59-
velocity: -itemScale * event.velocityX,
60-
stiffness: 900,
61-
damping: 100
62-
}
63-
)
53+
scrollIndex.value = withSpring(destValue, {
54+
velocity: -itemScale * event.velocityX,
55+
stiffness: 900,
56+
damping: 100
57+
})
6458

6559
if (onGestureEnd != null) runOnJS(onGestureEnd)(destValue)
6660
})

0 commit comments

Comments
 (0)