ant-design / compatible

https://compatible.now.sh
MIT License
89 stars 23 forks source link

JSX element type 'FormItem' is not a constructor function for JSX elements. #40

Open TonyaQi opened 4 years ago

TonyaQi commented 4 years ago

react 16.13.1 @types/react 16.9.34

升级迁移 兼容V3时 Form & FormItem报错

// tsconfig { "compilerOptions": { "baseUrl": "src", "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react", "experimentalDecorators": true, "noImplicitThis": false }, "include": [ "src" ], "extends": "./paths.json" }

                    <LegacyForm.Item label={index === 0 ? '部门' : ''} >
                        {form.getFieldDecorator(`departmentIds[_${item}]`, {
                            rules: required === false ? [] : [{ required: true, message: '请选择部门' }],
                            initialValue: index < (departmentList || []).length  ? initDepartmentObj[item] : undefined
                        })(
                            <Cascader
                                options={getOptions(data)}
                                placeholder="请选择"
                                className={styles['multiple-select-cascader']}
                                displayRender={(label:any) => label.join(' - ')}
                                getPopupContainer={(triggerNode:{parentNode:React.ReactNode}) => triggerNode.parentNode}
                                {...rst}
                            />
                        )}
                    </LegacyForm.Item>
shaodahong commented 4 years ago

Please provide a online reproduction by CodeSandbox or github repo

TonyaQi commented 4 years ago

Please provide a online reproduction by CodeSandbox or github repo

https://codesandbox.io/embed/empty-resonance-pt1vm?fontsize=14&hidenavigation=1&theme=dark

在codesandbox可以运行 看起来像是tsconfig配置问题?

shaodahong commented 4 years ago

看起来像是 include 的问题

TonyaQi commented 4 years ago

在d.ts 增加 declare module '@ant-design/compatible'; 解决了这个问题

Charismara commented 2 years ago

i'm struggling on the same problem. Is there a workaround for this?