Skip to content

Commit 6035538

Browse files
authored
fix: __reanimatedLoggerConfig is not defined on edge runtime (#6880)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary If you run NextJs application in edge runtime, library throws an error `__reanimatedLoggerConfig is not defined` we needs to declare global or globalThis on every usage in workers on edge runtime. ## Collaboration **It was found and made in collaboration with @vault-developer** ## Test plan Tested with patch-package and it worked
1 parent 21eea19 commit 6035538

File tree

1 file changed

+3
-3
lines changed
  • packages/react-native-reanimated/src/logger

1 file changed

+3
-3
lines changed

packages/react-native-reanimated/src/logger/logger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function registerLoggerConfig(config: LoggerConfigInternal) {
9393
*/
9494
export function replaceLoggerImplementation(logFunction: LogFunction) {
9595
'worklet';
96-
registerLoggerConfig({ ...__reanimatedLoggerConfig, logFunction });
96+
registerLoggerConfig({ ...global.__reanimatedLoggerConfig, logFunction });
9797
}
9898

9999
/**
@@ -108,7 +108,7 @@ export function replaceLoggerImplementation(logFunction: LogFunction) {
108108
export function updateLoggerConfig(options?: Partial<LoggerConfig>) {
109109
'worklet';
110110
registerLoggerConfig({
111-
...__reanimatedLoggerConfig,
111+
...global.__reanimatedLoggerConfig,
112112
// Don't reuse previous level and strict values from the global config
113113
level: options?.level ?? DEFAULT_LOGGER_CONFIG.level,
114114
strict: options?.strict ?? DEFAULT_LOGGER_CONFIG.strict,
@@ -125,7 +125,7 @@ function handleLog(
125125
options: LogOptions
126126
) {
127127
'worklet';
128-
const config = __reanimatedLoggerConfig;
128+
const config = global.__reanimatedLoggerConfig;
129129
if (
130130
// Don't log if the log is marked as strict-only and the config doesn't
131131
// enable strict logging

0 commit comments

Comments
 (0)