From 66601e755fcad10698e61d20878d52194ad0e90c Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 8 Jan 2020 13:28:44 -0800 Subject: [PATCH] Attempted fix for view parenting issue Summary: View should reset whether we are inside of a text or not. For example, inline images should only be rendered inside text, but if we have a view inside text, then it should render a regular image, not an inline image. This logic *should* exist in native instead of in JS, but this is an easier change for now. I'm sad to have to turn this back into a JS component instead of just being the string 'RCTView' as this will have performance implications on all surfaces, but this is how it always used to be so maybe it's fine. This example previously crashed, and no longer does: ``` function PlaygroundContent(props: {}) { return ( ); } ``` Changelog: [General][Fixed] Fixes bug where would crash. Reviewed By: JoshuaGross Differential Revision: D17564510 fbshipit-source-id: 0ecf49b3d466e7adf57a46a7a097dd3798c721a4 --- Libraries/Components/View/View.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index bd2c26f0e5d7d0..cba9b02a398ad5 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -11,7 +11,10 @@ 'use strict'; import type {ViewProps} from './ViewPropTypes'; -import type {ViewNativeComponentType} from './ViewNativeComponent'; + +const React = require('react'); +import ViewNativeComponent from './ViewNativeComponent'; +const TextAncestor = require('../../Text/TextAncestor'); export type Props = ViewProps; @@ -22,5 +25,17 @@ export type Props = ViewProps; * * @see http://facebook.github.io/react-native/docs/view.html */ -module.exports = (require('./ViewNativeComponent') - .default: ViewNativeComponentType); +const View: React.AbstractComponent< + ViewProps, + React.ElementRef, +> = React.forwardRef((props: ViewProps, forwardedRef) => { + return ( + + + + ); +}); + +View.displayName = 'View'; + +module.exports = View;