我正在尝试使用typescript 2.3创建表单redux-form 6.6.3并做出反应。我已经安装了类型定义@ types / redux-form 6.6.2。这是表格:
import * as React from 'react';
import { reduxForm, Field } from 'redux-form';
import styles from '../../styles/styles';
class CreateFunction extends React.Component < any, any > {
private required = (value) => (value == null ? 'required' : undefined);
private handleSubmit = () =>{}
public render() {
return (
<div style={{ marginTop: 30 }}>
<form onSubmit={this.handleSubmit}>
<Field name="name" component="input"
hintText="Veuillez saisir la fonction"
floatingLabelText="Fonction"
style={styles.textField}
validate={this.required}
/>
</form>
</div>
);
}
}
const createFunction = reduxForm({
form: 'createFunctionForm',
})(CreateFunction);
export default createFunction;
但是一旦CreateFunction导入如下:
import createFunction from '../../functions/containers/functiolList';
并像这样使用:
<createFunction />
我无法构建,并且我收到了此错误消息:
severity: 'Error'
message: 'Property 'createFunction' does not exist on type 'JSX.IntrinsicElements'.'
at: '66,9'
source: 'ts'
答案 0 :(得分:1)
尝试导入名称以capital letter开头的
import CreateFunction from '../../functions/containers/functiolList';
然后:
<CreateFunction/>
如果您引用以小写字母开头的自定义组件 - 它将被视为内置组件而非您的自定义组件。