在使用React Native组件时,需要在组件名后面加上.NativeComponent
来表示该组件是原生React Native组件,而非JSX组件。
例如,当安装了@types/styled-components-react-native后,不再能直接使用React Native提供的View
组件,需要使用View.NativeComponent
来替代。代码示例如下:
import React from 'react'; import { View } from 'react-native'; import styled from 'styled-components/native';
const StyledView = styled(View.NativeComponent) background-color: blue;
;
export default function App() {
return (
上一篇:安装了@react-navigation/stack后出现的错误
下一篇:安装了AccessDeveloperExtensions.exe和AccessRuntime.exe后,无法将MS Access 2007报表导出。