ant-design-mobile-rn
ant-design-mobile-rn copied to clipboard
React Native 0.69.1 + TS Provider ts 报错
<Provider>
<NavigationContainer>
<Stack.Navigator
initialRouteName={Views.Home}
screenOptions={{
headerShadowVisible: false,
headerTitleAlign: 'center',
headerTitleStyle: {
fontSize: 16,
color: '#333333',
fontFamily: 'PingFangSC-Semibold',
fontWeight: '700'
}
}}>
<Stack.Screen name={Views.Home} component={Home} options={{ title: '首页' }} />
<Stack.Screen name={Views.Center} component={Center} options={{ title: '个人中心' }} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
![image](https://user-images.githubusercontent.com/29221830/178086785-f495471d-cb80-47e8-8fcc-08f850d1de60.png)
rn 当前版本没有link
命令 但字体并未自动连接
Toast.success({ content: '测试' })
iOS模拟器报错:
@bang88 大佬看看呢,其次官方安装向导应该挺久不更新了,还停留在需要运行react-native link 且文档也没有说需要安装community等依赖,造成运行报错。
cc @1uokun
Question 1:
类型“{ children: Element; }”与类型“IntrinsicAttributes & IntrinsicClassAttributes<Provider> & Readonly<ProviderProps>”不具有相同的属性。
参考:https://stackoverflow.com/a/71879682/10506271 相关类型声明我们会紧跟补充
you should use
"@types/react": "17.0.39"
instead of
"@types/react": "18.0.3"
because react18 types is not yet compatible.
Question 2:
原因:借于0.60版本就提出的Autolinking
特性,react-native
在0.69版本彻底取消了link
命令,
未解决:至于为什么没有自动link成功,我们会在@ant-design/icons-react-native
这个库中排查
文档:后续会参考(commit: Fix autolinking with React Native 0.69)来更新文档
参考:https://stackoverflow.com/a/72831181/10506271
https://github.com/react-native-community/cli/releases/tag/v8.0.0
It seems like
link
andunlink
commands have been removed from react-native cli. You can rely on autolinking to complete your library installtion and react-native-vector-icons does support autolinking.Please follow installation instructions directly from library README.md as documentation in other places might be outdated.
感谢你为我们带来的rn最新版本的开发体验,有兴趣可以和我们一起参与贡献[嘿哈]
Question 2:
- package.json 将react-native版本修改为0.68以下,例如 "react-native": "0.67.0"
- 执行yarn
- 执行 react-native link @ant-design/icons-react-native (此处就会link)
- pod install 后 run app
- 将步骤1修改回去, yarn
fixed in 5.0.1
在5.0.1 WingBlank 还是有问题 @1uokun
Overload 1 of 2, '(props: WingBlankProps | Readonly<WingBlankProps>): WingBlank', gave the following error.
Type '{ children: Element[]; style: { flex: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<WingBlank> & Pick<Readonly<WingBlankProps>, "style"> & InexactPartial<...> & InexactPartial<...>'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<WingBlank> & Pick<Readonly<WingBlankProps>, "style"> & InexactPartial<...> & InexactPartial<...>'.
react18 类型没有children补上了吗?
react18 类型没有children补上了吗?
可以先通过 patch的方式 修复
diff --git a/node_modules/@ant-design/react-native/lib/badge/index.d.ts b/node_modules/@ant-design/react-native/lib/badge/index.d.ts
index 6b6debc..2eabdc8 100644
--- a/node_modules/@ant-design/react-native/lib/badge/index.d.ts
+++ b/node_modules/@ant-design/react-native/lib/badge/index.d.ts
@@ -9,6 +9,7 @@ export interface BadgeProps extends WithThemeStyles<BadgeStyle> {
corner?: boolean;
dot?: boolean;
text?: any;
+ children?: React.ReactNode;
}
export default class Badge extends React.Component<BadgeProps, any> {
static defaultProps: {
diff --git a/node_modules/@ant-design/react-native/lib/modal/Modal.d.ts b/node_modules/@ant-design/react-native/lib/modal/Modal.d.ts
index 22e4980..d4d8c80 100644
--- a/node_modules/@ant-design/react-native/lib/modal/Modal.d.ts
+++ b/node_modules/@ant-design/react-native/lib/modal/Modal.d.ts
@@ -10,6 +10,7 @@ export interface ModalProps extends ModalPropsType<TextStyle>, WithThemeStyles<M
style?: StyleProp<ViewStyle>;
bodyStyle?: StyleProp<ViewStyle>;
onRequestClose?: CallbackOnBackHandler;
+ children: React.ReactNode;
}
declare class AntmModal extends React.Component<ModalProps, any> {
static defaultProps: {
diff --git a/node_modules/@ant-design/react-native/lib/wing-blank/index.d.ts b/node_modules/@ant-design/react-native/lib/wing-blank/index.d.ts
index feda77b..a429438 100644
--- a/node_modules/@ant-design/react-native/lib/wing-blank/index.d.ts
+++ b/node_modules/@ant-design/react-native/lib/wing-blank/index.d.ts
@@ -3,6 +3,7 @@ import { StyleProp, ViewStyle } from 'react-native';
export interface WingBlankProps {
style?: StyleProp<ViewStyle>;
size?: 'sm' | 'md' | 'lg';
+ children?: React.ReactNode;
}
declare class WingBlank extends React.Component<WingBlankProps, any> {
static defaultProps: {