Skip to content

Commit

Permalink
Animated: Restore AnimatedNode.prototype.toJSON (#46498)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46498

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()`.

Reviewed By: javache

Differential Revision: D62690380

fbshipit-source-id: d5b7c1d156b49838abefe48a7d7b61471cc3488a
  • Loading branch information
yungsters authored and cipolleschi committed Sep 16, 2024
1 parent 3b44182 commit 83eb95e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
"
`;
Expand Down

0 comments on commit 83eb95e

Please sign in to comment.