diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index 8ca9401597ddb..c71a9050211cf 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -22,8 +22,6 @@ import type { import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils'; import {create, diff} from './ReactNativeAttributePayload'; -import invariant from 'shared/invariant'; - import {dispatchEvent} from './ReactFabricEventEmitter'; import { @@ -264,10 +262,11 @@ export function createTextInstance( hostContext: HostContext, internalInstanceHandle: Object, ): TextInstance { - invariant( - hostContext.isInAParentText, - 'Text strings must be rendered within a component.', - ); + if (__DEV__) { + if (!hostContext.isInAParentText) { + console.error('Text strings must be rendered within a component.'); + } + } const tag = nextReactTag; nextReactTag += 2; diff --git a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js index c7e4e3dee1b51..9f2851382af43 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js @@ -524,7 +524,7 @@ describe('ReactFabric', () => { }); }); - it('should throw for text not inside of a ancestor', () => { + it('should console error for text not inside of a ancestor', () => { const ScrollView = createReactNativeComponentClass('RCTScrollView', () => ({ validAttributes: {}, uiViewClassName: 'RCTScrollView', @@ -542,7 +542,7 @@ describe('ReactFabric', () => { act(() => { ReactFabric.render(this should warn, 11); }); - }).toThrow('Text strings must be rendered within a component.'); + }).toErrorDev(['Text strings must be rendered within a component.']); expect(() => { act(() => { @@ -553,7 +553,7 @@ describe('ReactFabric', () => { 11, ); }); - }).toThrow('Text strings must be rendered within a component.'); + }).toErrorDev(['Text strings must be rendered within a component.']); }); it('should not throw for text inside of an indirect ancestor', () => {