Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TonyaQi opened this issue Apr 14, 2020 · 5 comments

Comments

@TonyaQi
Copy link

TonyaQi commented Apr 14, 2020

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
Copy link
Member

Please provide a online reproduction by CodeSandbox or github repo

@TonyaQi
Copy link
Author

TonyaQi commented Apr 15, 2020

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
Copy link
Member

看起来像是 include 的问题

@TonyaQi
Copy link
Author

TonyaQi commented Apr 15, 2020

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

@Charismara
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Charismara @shaodahong @TonyaQi and others