Skip to content

Commit 0aa2b52

Browse files
authored
fix: crash when RNWC isn't initialized yet (#199)
1 parent 38b53d7 commit 0aa2b52

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

package/example/AppExampleFabric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
8-
"start": "cd ../Shared && yarn start",
8+
"start": "cd ../Shared && yarn start --reset-cache",
99
"typescript": "tsc --noEmit",
1010
"pods": "cd ios && bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install",
1111
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",

package/example/AppExamplePaper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
8-
"start": "cd ../Shared && IS_NEW_ARCH=false yarn start",
8+
"start": "cd ../Shared && IS_NEW_ARCH=false yarn start --reset-cache",
99
"typescript": "tsc --noEmit",
1010
"pods": "cd ios && bundle install && RCT_NEW_ARCH_ENABLED=0 bundle exec pod install",
1111
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",

package/src/native/FilamentProxy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TFilamentRecorder } from './FilamentRecorder'
88
import { Choreographer } from '../types/Choreographer'
99
import { Dispatcher } from './Dispatcher'
1010
import { FilamentModule } from './FilamentModule'
11+
import { Worklets } from 'react-native-worklets-core'
1112

1213
interface TestHybridObject {
1314
int: number
@@ -119,4 +120,9 @@ if (!proxy.hasWorklets) {
119120

120121
export const FilamentProxy = proxy
121122

123+
// We must make sure that the Worklets API (module) is initialized (as its possible a lazy-loaded CxxTurboModule),
124+
// to initialize we must only call any property of the module:
125+
Worklets.defaultContext
126+
127+
// Create our custom RNF worklet context:
122128
export const FilamentWorkletContext = proxy.createWorkletContext()

0 commit comments

Comments
 (0)