Skip to content

Commit

Permalink
Animated: Restore AnimatedNode.prototype.toJSON
Browse files Browse the repository at this point in the history
Summary:
Looks like this is still necessary because we still run into this error when using the Components tab when using React DevTools:

> TypeError: cyclical structure in JSON object

This effectively reverts #46382.

Changelog:
[General][Changed] - AnimatedNode (and its subclasses) once again implement `toJSON()`.

Differential Revision: D62690380
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 14, 2024
1 parent afb40e9 commit 0852e82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ describe('Animated tests', () => {
expect(anim.__getValue()).toBe(15);
});

it('convert to JSON', () => {
expect(JSON.stringify(new Animated.Value(10))).toBe('10');
});

it('bypasses `setNativeProps` in test environments', async () => {
const opacity = new Animated.Value(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,8 @@ export default class AnimatedNode {
__setPlatformConfig(platformConfig: ?PlatformConfig) {
this._platformConfig = platformConfig;
}

toJSON(): any {
return this.__getValue();
}
}

0 comments on commit 0852e82

Please sign in to comment.