为什么我在使用 react-web 时会出现这些错误

Why am I getting these errors with react-web

所以我正在尝试完成 React 网络教程以学习如何制作 Android 和 iOS 应用程序并且我一直在学习这个教程:https://www.youtube.com/watch?time_continue=469&v=_CBYbEGvxYY 但是当我尝试 运行 一个简单的页面来测试一些钩子时:

import React, { useState } from 'react';
import logo from './logo.svg';
import { TextComponent } from 'react-native';

const App = () => {
  const[count, setCount] = useState(0);
  return (
    <view>
      <text>{count}</text>
      <button title="Increment" onKeyPress={()=> setCount(count + 1)}>Increment</button>
    </view>
  );
}

export default App;

我收到以下控制台错误:

Warning: The tag <text> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
    in text (at App.tsx:9)
    in view (at App.tsx:8)
    in App
    in div (created by View)
    in View (created by AppContainer)
    in div (created by View)
    in View (created by AppContainer)
    in AppContainer

而且程序根本不增加计数。我还尝试将标签名称更改为大写字母,就像错误提示的那样,但这不起作用,因为标签无法识别。有人可以帮帮我吗? 注意:我对为什么我现在收到这些错误感到困惑,因为以前当我只有一个带有文本的简单视图时,程序运行正常但现在我收到这些错误....

HTML 中没有名为 <text> 的标签。在视频中,他们导入了:

import { View, Text } from 'react-native';

因此您需要确保导入和使用正确的组件。它们区分大小写:

import React, { useState } from 'react';
import logo from './logo.svg';
import { View, Text } from 'react-native';

const App = () => {
  const[count, setCount] = useState(0);
  return (
    <View>
      <Text>{count}</Text>
      <button title="Increment" onKeyPress={()=> setCount(count + 1)}>Increment</button>
    </View>
  );
}

export default App;