diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedNode.js b/packages/react-native/Libraries/Animated/nodes/AnimatedNode.js index 6f4ba16ce20378..ff4c7f5d701922 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedNode.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedNode.js @@ -203,4 +203,12 @@ export default class AnimatedNode { __setPlatformConfig(platformConfig: ?PlatformConfig) { this._platformConfig = platformConfig; } + + /** + * NOTE: This is intended to prevent `JSON.stringify` from throwing "cyclic + * structure" errors in React DevTools. Avoid depending on this! + */ + toJSON(): mixed { + return this.__getValue(); + } } diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index bdba8d92d83758..15a06a9ac22227 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -930,6 +930,7 @@ exports[`public API should not change unintentionally Libraries/Animated/nodes/A toJSON(): any; __getPlatformConfig(): ?PlatformConfig; __setPlatformConfig(platformConfig: ?PlatformConfig): void; + toJSON(): mixed; } " `;