GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Show a soft error when a text string or number is supplied as a child… · react/react@e9b2028

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-native-renderer/src
    • ReactFabricHostConfig.js
    • ReactNativeHostConfig.js
    • __tests__
      • ReactFabric-test.internal.js
      • ReactNativeMount-test.internal.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-native-renderer/src/ReactFabricHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabricHostConfig.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import type {
2222
import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
2323
import {create, diff} from './ReactNativeAttributePayload';
2424

25-
import invariant from 'shared/invariant';
26-
2725
import {dispatchEvent} from './ReactFabricEventEmitter';
2826

2927
import {
@@ -264,10 +262,11 @@ export function createTextInstance(
264262
hostContext: HostContext,
265263
internalInstanceHandle: Object,
266264
): TextInstance {
267-
invariant(
268-
hostContext.isInAParentText,
269-
'Text strings must be rendered within a <Text> component.',
270-
);
265+
if (__DEV__) {
266+
if (!hostContext.isInAParentText) {
267+
console.error('Text strings must be rendered within a <Text> component.');
268+
}
269+
}
271270

272271
const tag = nextReactTag;
273272
nextReactTag += 2;
Collapse file

‎packages/react-native-renderer/src/ReactNativeHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeHostConfig.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ export function createTextInstance(
147147
hostContext: HostContext,
148148
internalInstanceHandle: Object,
149149
): TextInstance {
150-
invariant(
151-
hostContext.isInAParentText,
152-
'Text strings must be rendered within a <Text> component.',
153-
);
154-
150+
if (__DEV__) {
151+
if (!hostContext.isInAParentText) {
152+
console.error('Text strings must be rendered within a <Text> component.');
153+
}
154+
}
155155
const tag = allocateTag();
156156

157157
UIManager.createView(
Collapse file

‎packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ describe('ReactFabric', () => {
524524
});
525525
});
526526

527-
it('should throw for text not inside of a <Text> ancestor', () => {
527+
it('should console error for text not inside of a <Text> ancestor', () => {
528528
const ScrollView = createReactNativeComponentClass('RCTScrollView', () => ({
529529
validAttributes: {},
530530
uiViewClassName: 'RCTScrollView',
@@ -542,7 +542,7 @@ describe('ReactFabric', () => {
542542
act(() => {
543543
ReactFabric.render(<View>this should warn</View>, 11);
544544
});
545-
}).toThrow('Text strings must be rendered within a <Text> component.');
545+
}).toErrorDev(['Text strings must be rendered within a <Text> component.']);
546546

547547
expect(() => {
548548
act(() => {
@@ -553,7 +553,7 @@ describe('ReactFabric', () => {
553553
11,
554554
);
555555
});
556-
}).toThrow('Text strings must be rendered within a <Text> component.');
556+
}).toErrorDev(['Text strings must be rendered within a <Text> component.']);
557557
});
558558

559559
it('should not throw for text inside of an indirect <Text> ancestor', () => {
Collapse file

‎packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ describe('ReactNative', () => {
473473
);
474474
});
475475

476-
it('should throw for text not inside of a <Text> ancestor', () => {
476+
it('should console error for text not inside of a <Text> ancestor', () => {
477477
const ScrollView = createReactNativeComponentClass('RCTScrollView', () => ({
478478
validAttributes: {},
479479
uiViewClassName: 'RCTScrollView',
@@ -487,9 +487,9 @@ describe('ReactNative', () => {
487487
uiViewClassName: 'RCTView',
488488
}));
489489

490-
expect(() => ReactNative.render(<View>this should warn</View>, 11)).toThrow(
491-
'Text strings must be rendered within a <Text> component.',
492-
);
490+
expect(() =>
491+
ReactNative.render(<View>this should warn</View>, 11),
492+
).toErrorDev(['Text strings must be rendered within a <Text> component.']);
493493

494494
expect(() =>
495495
ReactNative.render(
@@ -498,7 +498,7 @@ describe('ReactNative', () => {
498498
</Text>,
499499
11,
500500
),
501-
).toThrow('Text strings must be rendered within a <Text> component.');
501+
).toErrorDev(['Text strings must be rendered within a <Text> component.']);
502502
});
503503

504504
it('should not throw for text inside of an indirect <Text> ancestor', () => {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.