@bacons/反应-视图
想象一下,如果你可以使用 react-native-web 道具没有断裂 react-native 应用或填入 TypeScript 错误。 我希望有朝一日这个一揽子方案能够停止存在.
将软件包添加到您的 npm 依赖性
yarn add @bacons/react-views
使用量
与反应-内生网和反应-内生网相配合的 View, Text, and Image 的倒置替换. 添加 hoverStyle 网络的样式道具(不支持前置命令).
import { View, Image, Text, StyleSheet, Pressable } from "@bacons/react-views";
function App() {
return (
<>
<View
accessibilityRole="main"
style={{
// These styles do nothing on native.
transitionDuration: "200ms",
}}
hoverStyle={{
backgroundColor: "darkturquoise",
}}
// A custom prop that centers contents, because I'm lazy.
center
>
{/* No TypeScript errors... */}
<Text href="#">Link</Text>
<Text accessibilityRole="heading" accessibilityLevel={1}>
Header
</Text>
</View>
</>
);
}
大部分都增加了类型 所以应该不会太高了 这些风格在本地平台上都得到了评价,不过,这之后没有太多的间接费用 StyleSheet API除了加入打入道具外,在本土上不做任何事情.
StyleSheet财务报告和审定财务报表Pressable只调整类型.