[英]ClassName props is missing in object type. Flow and CSS Modules
我已經使用 CLI quickstart初始化了一個 React Native 應用程序。 我編輯的唯一一件事是我使用 CSS Modules 來設置組件的樣式(注意:className 而不是 style)。 我想用 flow 對項目進行類型檢查,如果我運行 flow 它會出現以下錯誤。
我無法創建 View 元素,因為屬性className
在對象類型 [1] 中缺失,但在 props [2] 中存在。
我能做什么?
// @flow
import React from "react";
import {
View,
Text
} from "react-native";
import styles from "./base.sass";
const App = () => {
const [title] = React.useState("Hello");
return (
<View className={styles.title}>
<Text>{title}</Text>
</View>
);
};
export default App;
它不是 React.js,你不能那樣使用。 這是一個例子。
import React from "react";
import {
View,
Text,
StyleSheet
} from "react-native";
const App = () => {
const [title] = React.useState("Hello");
return (
<View style={styles.title}>
<Text>{title}</Text>
</View>
);
};
const styles = StyleSheet.create({
title: {
justifyContent: 'center',
alignItems: 'center',
}
});
export default App;
從 0.11 開始, className
道具已從 View 中刪除: https : //github.com/necolas/react-native-web/issues/1146
請檢查您使用的版本!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.