Skip to content

Commit

Permalink
Native Animated: Prevent views driven by native animated from being o…
Browse files Browse the repository at this point in the history
…ptimized away

Summary:
When using native animated we don't go through the shadow thread and use the NativeViewHierachyOptimizer so we have to make sure the views won't get optimized away. Also since we are not passing certain props because they are driven by native it is possible that the view will be marked as layout only when in fact it is not.

**Test plan**
Animated a simple view that will be collapsed with native animated and reproduce the error (it's actually just an error log in logcat now and no longer a redscreen) and checked that this fixes it.

Fixes #12975
Closes #12983

Differential Revision: D4811420

Pulled By: javache

fbshipit-source-id: f217f244baca64df2b76cbe08cce2d847c0dc985
  • Loading branch information
janicduplessis authored and facebook-github-bot committed May 26, 2017
1 parent a2e589e commit c87524e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,16 @@ function createAnimatedComponent(Component: any): any {
}

render() {
const props = this._propsAnimated.__getValue();
return (
<Component
{...this._propsAnimated.__getValue()}
{...props}
ref={this._setComponentRef}
// The native driver updates views directly through the UI thread so we
// have to make sure the view doesn't get optimized away because it cannot
// go through the NativeViewHierachyManager since it operates on the shadow
// thread.
collapsable={this._propsAnimated.__isNative ? false : props.collapsable}
/>
);
}
Expand Down

0 comments on commit c87524e

Please sign in to comment.