【问题标题】:View Button, Text, boolean and string don't exist查看按钮、文本、布尔值和字符串不存在
【发布时间】:2021-05-31 23:04:40
【问题描述】:

我不明白我在这里做错了什么。视图、按钮、文本、布尔值和字符串不起作用,它说它不存在

import React, { useState, useEffect } from "react";
import styled from "styled-components/native";
import Voice from "react-native-voice";

const Container = styled.View`
  flex: 1;
  justify-content: center;
  align-items: center;
  background-color: #f5fcff;
`
const ButtonRecord = styled.Button``;
const VoiceText = styled.Text`
  margin: 32px;
`;

const Voz = () => {
   const [isRecord, setIsRecord] = useState<boolean>(false);
   const [text, setText] = useState<string>("");

【问题讨论】:

  • 应该是styled.viewstyled.button(小写)。你确定你在 TypeScript 中运行它吗?您不必将泛型添加到 useState 调用中,因为它们是由您提供的值推断出来的。
  • 小写不能解决问题
  • 对不起,我没有注意到它是原生的。大写版本是正确的。我能够在沙箱中运行此代码而不会出错。
  • 真的吗?那我不明白
  • 你能创建一个reproducible example吗?

标签: android css reactjs native tsx


【解决方案1】:

确保导入您在 React 应用中使用的所有库。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 2012-08-10
    • 2019-10-15
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    相关资源
    最近更新 更多