ant-design-mobile-rn icon indicating copy to clipboard operation
ant-design-mobile-rn copied to clipboard

React Native 0.69.1 + TS Provider ts 报错

Open Es-Rell opened this issue 2 years ago • 4 comments

<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

rn 当前版本没有link命令 但字体并未自动连接

Toast.success({ content: '测试' })

iOS模拟器报错: image

Es-Rell avatar Jul 09 '22 01:07 Es-Rell

@bang88 大佬看看呢,其次官方安装向导应该挺久不更新了,还停留在需要运行react-native link 且文档也没有说需要安装community等依赖,造成运行报错。

Es-Rell avatar Jul 09 '22 13:07 Es-Rell

cc @1uokun

BANG88 avatar Jul 10 '22 11:07 BANG88

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 and unlink 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最新版本的开发体验,有兴趣可以和我们一起参与贡献[嘿哈]

1uokun avatar Jul 15 '22 07:07 1uokun

Question 2:

  1. package.json 将react-native版本修改为0.68以下,例如 "react-native": "0.67.0"
  2. 执行yarn
  3. 执行 react-native link @ant-design/icons-react-native (此处就会link)
  4. pod install 后 run app
  5. 将步骤1修改回去, yarn

surrenderios avatar Jul 30 '22 05:07 surrenderios

fixed in 5.0.1

1uokun avatar Aug 17 '22 07:08 1uokun

在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<...>'.

lhr000lhr avatar Sep 15 '22 00:09 lhr000lhr

react18 类型没有children补上了吗?

freedomTT avatar Sep 28 '22 06:09 freedomTT

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: {

lhr000lhr avatar Sep 29 '22 01:09 lhr000lhr