Skip to content

Commit

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

Deletes the `AnimatedNode.prototype.toJSON` method.

It was originally introduced by [#7442](#7442) as a means to resolve [#7441](#7441), where an error occurs attempting to serialize `AnimatedNode` instances.

However, this is no longer needed for that purpose because our inspector implementation is now more resilient. (It correctly reports the current style value instead of the `AnimatedNode` instance.)

The impetus for this change is that this `toJSON` method prevents a future performance optimization for all `Animated` components.

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

Reviewed By: javache

Differential Revision: D62350726

fbshipit-source-id: c68edc98878e58d48bc677c4f1299bb1bd15c9c4
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 10, 2024
1 parent ca234ba commit fe62285
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ 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 @@ -182,10 +182,6 @@ export default class AnimatedNode {
);
}

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

__getPlatformConfig(): ?PlatformConfig {
return this._platformConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,6 @@ exports[`public API should not change unintentionally Libraries/Animated/nodes/A
__callListeners(value: number): void;
__getNativeTag(): number;
__getNativeConfig(): Object;
toJSON(): any;
__getPlatformConfig(): ?PlatformConfig;
__setPlatformConfig(platformConfig: ?PlatformConfig): void;
}
Expand Down

0 comments on commit fe62285

Please sign in to comment.