如何解决“不变违反:文本字符串必须在<text>组件内呈现”?

时间:2019-07-03 12:42:43

标签: react-native

我已经完成了在互联网上搜索过的所有内容,但仍然会造成一些麻烦

来自Home.js的代码

import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default class Home extends React.Component {
    render() {
        return (<View><text>hihihi</text></View>);
    }
}

来自app.js的代码

import React from "react";
import Home from "./app/views/Home.js"
export default class App extends React.Component {
  render() {
    return (<Home />);
  }
}

1 个答案:

答案 0 :(得分:1)

更改

import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default class Home extends React.Component {
    render() {
        return (<View><text>hihihi</text></View>);
    }
}

import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default class Home extends React.Component {
    render() {
        return (<View><Text>hihihi</Text></View>);
    }
}

它是</Text>而不是</text> T是大写字母