Skip to content

Commit

Permalink
Add a possibility to disable some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiPl01 committed Aug 13, 2024
1 parent 72beef5 commit d538f1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions apps/common-app/src/examples/InvalidValueAccessExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import Animated, {
withTiming,
} from 'react-native-reanimated';

Animated.configureLogger({
strict: true,
});

export default function InvalidValueAccessExample() {
const [counter, setCounter] = React.useState(0);
const [updateFromUseEffect, setUpdateFromUseEffect] = React.useState(false);
Expand Down
11 changes: 7 additions & 4 deletions packages/react-native-reanimated/src/mutables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
import { shouldBeUseWeb } from './PlatformChecker';
import type { Mutable } from './commonTypes';
import { logger } from './logger';
import { isFirstReactRender, isReactRendering } from './reactUtils';
import { shareableMappingCache } from './shareableMappingCache';
import { makeShareableCloneRecursive } from './shareables';
Expand All @@ -15,16 +16,18 @@ function shouldWarnAboutAccessDuringRender() {

function checkInvalidReadDuringRender() {
if (shouldWarnAboutAccessDuringRender()) {
console.warn(
'[Reanimated] Reading from `value` during component render. Please ensure that you do not access the `value` property while React is rendering a component.'
logger.warn(
'Reading from `value` during component render. Please ensure that you do not access the `value` property while React is rendering a component.',
{ strict: true }
);
}
}

function checkInvalidWriteDuringRender() {
if (shouldWarnAboutAccessDuringRender()) {
console.warn(
'[Reanimated] Writing to `value` during component render. Please ensure that you do not access the `value` property while React is rendering a component.'
logger.warn(
'Writing to `value` during component render. Please ensure that you do not access the `value` property while React is rendering a component.',
{ strict: true }
);
}
}
Expand Down

0 comments on commit d538f1e

Please sign in to comment.