Animated: Implement toJSON method of Animated

Summary:
Fix issue https://github.com/facebook/react-native/issues/7441
Closes https://github.com/facebook/react-native/pull/7442

Differential Revision: D3274594

fb-gh-sync-id: 720d7dcdaa97a2ee5235547bad6ba020398b57d2
fbshipit-source-id: 720d7dcdaa97a2ee5235547bad6ba020398b57d2
This commit is contained in:
wusuopu 2016-05-08 01:08:32 -07:00 committed by Facebook Github Bot 9
parent 0cd2904b23
commit 17f08070e8
2 changed files with 4 additions and 0 deletions

View File

@ -69,6 +69,7 @@ class Animated {
__getNativeConfig(): Object {
throw new Error('This JS animated node type cannot be used as native animated node');
}
toJSON(): any { return this.__getValue(); }
}
type AnimationConfig = {

View File

@ -142,6 +142,9 @@ describe('Animated', () => {
expect(anim.__getValue()).toBe(15);
});
it('convert to JSON', () => {
expect(JSON.stringify(new Animated.Value(10))).toBe('10');
});
});