【发布时间】: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.view和styled.button(小写)。你确定你在 TypeScript 中运行它吗?您不必将泛型添加到useState调用中,因为它们是由您提供的值推断出来的。 -
小写不能解决问题
-
对不起,我没有注意到它是原生的。大写版本是正确的。我能够在沙箱中运行此代码而不会出错。
-
真的吗?那我不明白
-
你能创建一个reproducible example吗?
标签: android css reactjs native tsx