noReactNativeRawText
Цей контент ще не доступний вашою мовою.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noReactNativeRawText - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
react-native/no-raw-text
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noReactNativeRawText": "error" } } }}Description
Section titled “Description”Disallow raw text outside <Text> components in React Native.
In React Native, every string rendered in the UI must be wrapped in a <Text>
component. Rendering text directly inside containers such as <View> throws at
runtime on native platforms.
By default, the following element names are treated as valid text containers:
Text, TSpan, StyledText, and Animated.Text. Additional components can be
whitelisted through the skip option.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<View>some text</View>code-block.jsx:1:7 lint/nursery/noReactNativeRawText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Raw text (some text) cannot be used outside of a <Text> tag.
> 1 │ <View>some text</View>
│ ^^^^^^^^^
2 │
ℹ In React Native, strings must be rendered within a <Text> component, otherwise the application throws at runtime.
ℹ Wrap the text in a <Text> component, or add the containing component to the skip option.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<View>{'some text'}</View>code-block.jsx:1:7 lint/nursery/noReactNativeRawText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Raw text (some text) cannot be used outside of a <Text> tag.
> 1 │ <View>{‘some text’}</View>
│ ^^^^^^^^^^^^^
2 │
ℹ In React Native, strings must be rendered within a <Text> component, otherwise the application throws at runtime.
ℹ Wrap the text in a <Text> component, or add the containing component to the skip option.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
const text = 'some text';<View>{`${text}`}</View>code-block.jsx:2:7 lint/nursery/noReactNativeRawText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Raw text (TemplateLiteral: text) cannot be used outside of a <Text> tag.
1 │ const text = ‘some text’;
> 2 │ <View>{`${text}`}</View>
│ ^^^^^^^^^^^
3 │
ℹ In React Native, strings must be rendered within a <Text> component, otherwise the application throws at runtime.
ℹ Wrap the text in a <Text> component, or add the containing component to the skip option.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
<View><Text>some text</Text></View><View><Text>{'some text'}</Text></View>Options
Section titled “Options”An array of additional component names that are allowed to contain raw text.
{ "linter": { "rules": { "nursery": { "noReactNativeRawText": { "options": { "skip": [ "Title" ] } } } } }}const Title = ({ children }) => <Text>{children}</Text>;<Title>This is the title</Title>;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.