Reduxフォームの「フィールド」コンポーネントを使用する際に問題があります。単純にredux形式のウェブサイトの例に従ってください。reduxフォーム、フィールドコンポーネントの問題
/* MyForm.jsx */
...
import { Field, reduxForm } from 'redux-form';
class MyForm extends Component {
...
<form onSubmit={handleSubmit(...)}>
<div>
<label>First Name</label>
<div>
<Field name="firstName" component="input" type="text" placeholder="First Name"/>
</div>
</div>
...
}
export default reduxForm({
form: 'myForm'
})(MyForm);
ここでreduxフォームを使用する親コンポーネントです。
/* page.jsx */
import MyForm from './MyForm';
...
<MyForm/>
...
フォームがレンダリングされませんし、コンソールにエラーが言う:
React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
をしかし、私は材料-UIまたはブートストラップフォームフィールドを使用している場合、それはうまく動作します。
私は、フォームの減速が以前の形式のレンダリングマウント:
import {reducer as formReducer} from 'redux-form';
const myReducer = combineReducers({
...
form: formReducer
});
フィールド・コンポーネントが動作しない理由を任意のアイデア?
ありがとう、
あなたはどのバージョンのreduxフォームを使用していますか? –
私は^ 5.3.2 –
を使用していますが、v 6.0にアップグレードしようとしましたか? –