mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Animated: Restore AnimatedNode.prototype.toJSON (#46498)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/46382. Changelog: [General][Changed] - AnimatedNode (and its subclasses) once again implement `toJSON()`. Reviewed By: javache Differential Revision: D62690380 fbshipit-source-id: d5b7c1d156b49838abefe48a7d7b61471cc3488a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7d621f5eb7
commit
7bd4a54968
@@ -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);
|
||||
|
||||
|
||||
@@ -189,4 +189,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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,6 +933,7 @@ exports[`public API should not change unintentionally Libraries/Animated/nodes/A
|
||||
__getNativeConfig(): Object;
|
||||
__getPlatformConfig(): ?PlatformConfig;
|
||||
__setPlatformConfig(platformConfig: ?PlatformConfig): void;
|
||||
toJSON(): mixed;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user