Skip to content

Revert "Append text string to <Text> error message (#19581)" #19723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ export function createTextInstance(
): TextInstance {
invariant(
hostContext.isInAParentText,
'Text string must be rendered within a <Text> component.\n\nText: %s',
text.length > 100 ? text.substr(0, 88) + ' (truncated)' : text,
'Text strings must be rendered within a <Text> component.',
);

const tag = nextReactTag;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native-renderer/src/ReactNativeHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ export function createTextInstance(
): TextInstance {
invariant(
hostContext.isInAParentText,
'Text string must be rendered within a <Text> component.\n\nText: %s',
text.length > 100 ? text.substr(0, 88) + ' (truncated)' : text,
'Text strings must be rendered within a <Text> component.',
);

const tag = allocateTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,7 @@ describe('ReactFabric', () => {
}));

expect(() => ReactFabric.render(<View>this should warn</View>, 11)).toThrow(
'Text string must be rendered within a <Text> component.\n\nText: this should warn',
);

expect(() =>
ReactFabric.render(<View>{'x'.repeat(200)}</View>, 11),
).toThrow(
`Text string must be rendered within a <Text> component.\n\nText: ${'x'.repeat(
88,
)} (truncated)`,
'Text strings must be rendered within a <Text> component.',
);

expect(() =>
Expand All @@ -581,9 +573,7 @@ describe('ReactFabric', () => {
</Text>,
11,
),
).toThrow(
'Text string must be rendered within a <Text> component.\n\nText: hi hello hi',
);
).toThrow('Text strings must be rendered within a <Text> component.');
});

it('should not throw for text inside of an indirect <Text> ancestor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,7 @@ describe('ReactNative', () => {
}));

expect(() => ReactNative.render(<View>this should warn</View>, 11)).toThrow(
'Text string must be rendered within a <Text> component.\n\nText: this should warn',
);

expect(() =>
ReactNative.render(<View>{'x'.repeat(200)}</View>, 11),
).toThrow(
`Text string must be rendered within a <Text> component.\n\nText: ${'x'.repeat(
88,
)} (truncated)`,
'Text strings must be rendered within a <Text> component.',
);

expect(() =>
Expand All @@ -441,9 +433,7 @@ describe('ReactNative', () => {
</Text>,
11,
),
).toThrow(
'Text string must be rendered within a <Text> component.\n\nText: hi hello hi',
);
).toThrow('Text strings must be rendered within a <Text> component.');
});

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