Ir al contenido

noReactNativeRawText

Esta página aún no está disponible en tu idioma.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noReactNativeRawText": "error"
}
}
}
}

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.

<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>

An array of additional component names that are allowed to contain raw text.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noReactNativeRawText": {
"options": {
"skip": [
"Title"
]
}
}
}
}
}
}
const Title = ({ children }) => <Text>{children}</Text>;
<Title>This is the title</Title>;