Skip to content

Commit

Permalink
Fix jest test crashes with animated components
Browse files Browse the repository at this point in the history
Summary:
In the jest test renderer, host components have null refs by default. `createAnimatedComponent` tries to access the ref in componentDidMount, which then crashes. This is particularly problematic when trying to update test data:

https://fb.workplace.com/groups/mpen00bs/permalink/494236684721027/?comment_id=510656413079054

Just checking for null fixes the issue and shouldn't affect anything else.

Reviewed By: TheSavior, yungsters

Differential Revision: D16777137

fbshipit-source-id: 0b9f7c5734c849f36318512ceffcc42dd44c58bb
  • Loading branch information
sahrens authored and facebook-github-bot committed Aug 13, 2019
1 parent 054d2fc commit a9c8103
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/Animated/src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function createAnimatedComponent(Component: any, defaultProps: any): any {
_attachNativeEvents() {
// Make sure to get the scrollable node for components that implement
// `ScrollResponder.Mixin`.
const scrollableNode = this._component.getScrollableNode
const scrollableNode = this._component?.getScrollableNode
? this._component.getScrollableNode()
: this._component;

Expand Down

0 comments on commit a9c8103

Please sign in to comment.